-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
51 lines (34 loc) · 1.26 KB
/
main.py
File metadata and controls
51 lines (34 loc) · 1.26 KB
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
42
43
44
45
46
47
48
49
from flask import Flask, render_template, request, redirect
from rpsls_logic import *
from rpsls_dictionaries import *
images =["Rock.png", "Paper.png", "Scissors.png", "Lizard.png", "Spock.png"]
app = Flask(__name__)
app.config['DEBUG'] = True
@app.route('/')
def index():
return render_template("index.html")
@app.route('/play', methods=["GET", "POST"])
def play():
if request.method == 'POST':
return render_template("play.html")
else:
return redirect('/')
@app.route('/winner', methods=["POST"])
def winner():
user_input = request.form['user_input']
computer_choice = get_computer_choice()
if user_input == computer_choice:
winneris = (f"You both choose {user_input}, tie!")
messageis = "Draw!!!"
else:
winneris = get_winner(user_input, computer_choice)
messageis = get_message(user_input, computer_choice)
return render_template("winner.html", user_input = user_input, computer_choice = computer_choice, winneris = winneris, messageis = messageis)
@app.route('/bye', methods=["POST"])
def bye():
if request.form['play_again'] == "False":
return render_template("bye.html")
else:
return render_template("play.html")
if __name__ == '__main__':
app.run()