-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
47 lines (33 loc) · 997 Bytes
/
main.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
from flask import Flask, current_app, render_template, request
from draftomatic import evaluate
import json
app = Flask(__name__)
# evaluate([], 0)
tot_analyzed = 0
@app.route("/<state>/<depth>")
def get_draft_eval(state, depth):
return evaluate(draft, int(depth))
@app.route("/")
def home():
print("123")
with open("view.html", 'r') as fraw:
return fraw.read()
@app.route("/d/<draft>/")
def draft_r(draft):
global tot_analyzed
if draft == ",":
draft = []
else:
draft = [int(x) for x in draft.split(',')]
depth = request.args.get('depth')
if depth is None:
depth = 3
evalu = json.loads(evaluate(draft, depth))
tot_analyzed += evalu[1]
return render_template('view.html', draft=draft, e=evalu, Depth=depth, Nodes_Analyzed=tot_analyzed)
@app.route("/file/<file_name>")
def files(file_name):
print("123")
with open(file_name, 'r') as fraw:
return fraw.read()
app.run(debug=True)