-
Notifications
You must be signed in to change notification settings - Fork 7
/
app.py
41 lines (31 loc) · 1 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from flask import Flask , render_template, request
# from flask_sqlalchemy import SQLAlchemy
import os
import game as g
app = Flask(__name__)
point = 0
@app.route('/' , methods = ["GET"])
def index():
return render_template("index.html")
@app.route('/submit', methods=['POST'])
def submit():
global point
value = request.form.get("value")
if value is None:
return render_template('index.html', s="Please select a valid input.", p=point)
scores = g.game(value)
score = str(scores[0])
choice = {1:"rock", 2:"paper", 3:"scissor"}
if score == "You Lost!":
points = "0"
point = 0
else:
point += scores[1]
points = str(point)
return render_template('index.html', s=score, p=points, you=choice[scores[2]], cpu=choice[scores[3]])
if __name__ == '__main__':
# app.run(debug = False)
# app.run(debug=True, port = 8000)
# app.run(host = '0.0.0.0', port = 88)
app.run(debug=False)
# app.run(debug=False, port = 8000)