-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
37 lines (26 loc) · 901 Bytes
/
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
import ast
from flask import Flask, render_template
import requests
import json
endpoint = "http://127.0.0.1:8000"
app = Flask(__name__)
headers = {
"Content-Type": "application/json"
}
@app.route('/play')
def hello_world(): # put application's code here
query = requests.get(f"{endpoint}/getquery/", headers=headers).content.decode("utf-8").replace('"','')
oldAnswers = ast.literal_eval(requests.get(f"{endpoint}/query/{query}", headers=headers).content.decode("utf-8"))["answers"]
answers = []
y = 0
for i in oldAnswers:
if y < 10:
modified_i = i.replace(query.lower(), '')
answers.append(modified_i)
y += 1
print(query.lower())
print(answers)
print(oldAnswers)
return render_template('play.html', query=query, answers=answers)
if __name__ == '__main__':
app.run(Debug=True)