-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWebsite.py
70 lines (51 loc) · 1.79 KB
/
Website.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
'''
This is the main file that actually runs the Krypto game
It uses a package called flask, which handles interactions between server and client side
Running this file (calling app.run()), should set up a local server for development
'''
import sys
from json import dumps
from flask import Flask, render_template, request
import back_end
app = Flask(__name__)
app.debug = True
#this sets up the connection to the client side using the current url "/"
@app.route("/", methods=['GET', 'POST'])
def index():
'''
when a request is received from the client (in the do_ajax() function)
This calls our back_end code which finds a krypto hand with a valid solution
for the given difficulty level
'''
if request.method == "POST":
#get the difficulty of the request
difficulty = request.form["difficulty"]
#call the back end to create the hand with given difficulty
info = back_end.Run.run(difficulty)
#return the info for the game as a json file, which can be parsed in javascript
return dumps(info)
#this renders the html file from within the templates folder
return render_template("index.html")
@app.route('/about')
def about():
return render_template('about.html')
@app.route('/krypto')
def Krypto():
return render_template('projects/krypto.html')
@app.route('/dove')
def Dove():
return render_template('projects/dove.html')
@app.route('/ollie')
def Ollie():
return render_template('projects/ollie.html')
@app.route('/deka')
def DEKA():
return render_template('projects/deka.html')
@app.route('/circuits')
def Circuits():
return render_template('projects/circuits.html')
@app.route('/corolla')
def Toyota ():
return render_template('projects/corolla.html')
if __name__ == "__main__":
app.run(host='0.0.0.0')