-
Notifications
You must be signed in to change notification settings - Fork 0
/
chainsnake.py
41 lines (34 loc) · 1.11 KB
/
chainsnake.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
#!~/usr/bin/python3
from flask import Flask, request, render_template
import pymysql
import json
import chainsnakedb
app = Flask(__name__)
@app.route('/setup')
def fetch():
set_to_fetch = request.args.get('fetch')
chaindb = chainsnakedb.ChainsDb()
response = chaindb.get_questions_given_question("The chairman of China")
response["topic"] = set_to_fetch
response["description"] = "Information about important figures in political history of China"
return json.dumps(response)
@app.route('/hello/<u_name>')
def address(u_name):
return 'hey {}! did you know that harris is gay'.format(u_name)
@app.route('/getnext')
def question():
key = request.args.get('key')
chaindb = chainsnakedb.ChainsDb()
response = chaindb.get_questions_given_question(key)
return json.dumps(response)
@app.route('/question')
def word():
key = request.args.get('key')
chaindb = chainsnakedb.ChainsDb()
response = chaindb.get_keyword_given_question(key)
return json.dumps(response)
@app.route('/')
def index():
return render_template('index.html')
if __name__ == '__main__':
app.run()