-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
32 lines (21 loc) · 855 Bytes
/
app.py
File metadata and controls
32 lines (21 loc) · 855 Bytes
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
from flask import Flask, render_template, request
import json
import test_task
app = Flask(__name__)
with open('test_stations.json', 'r', encoding='utf-8') as metro_graph:
stations = json.load(metro_graph)['stations']
slver = test_task.create_solver_connection()
@app.route('/')
def maps():
return render_template("mapbasics.html", data=stations)
@app.route('/', methods=['POST'])
def maps_post():
text = request.form['station']
processed = test_task.solve_text_case(text, slver)
total_time = sum(processed[1])
processed[1].append(None)
processed_text_time = list(zip(processed[0], processed[1]))
# print(list(processed_text_time))
return render_template('mapbasics.html', data=stations, processed_text_time=processed_text_time, total_time=total_time), 201
if __name__ == '__main__':
app.run(debug=True)