-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
65 lines (52 loc) · 1.75 KB
/
app.py
File metadata and controls
65 lines (52 loc) · 1.75 KB
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
from flask import Flask, request, jsonify
from flask_cors import CORS
from jackinator import Thothnator
app = Flask(__name__)
CORS(app)
app.config['JSON_AS_ASCII'] = False
app.config['CORS_HEADERS'] = 'Content-Type'
thothnator = Thothnator()
@app.route('/', methods=['GET'])
def get_json_from_dictionary():
dic = {
'hello': 'world',
}
return jsonify(dic)
@app.route('/questions', methods=['GET'])
def get_quesion():
q = thothnator.decideQ()
thothnator.q_list.append(q)
res = {"question": q}
return jsonify(res)
@app.route('/answers', methods=['GET'])
def get_answer():
# count = request.json('count')
question = request.args.get('question')
answer = int(request.args.get('answer'))
thothnator.a_list.append(answer)
thothnator.p = thothnator.updateP(thothnator.p, question, answer)
if thothnator.isNeedContinueQ():
result = ''
res = {'continue': True, 'result': result}
else:
result = thothnator.getBestEstimate()
thothnator.updateDatabase
res = {'continue': False, 'result': result}
return jsonify(res)
# @app.route('/questions', methods=['POST'])
# def post_question():
# # count = request.json('count')
# question = request.json['question']
# answer = request.json['answer']
# thothnator.a_list.append(answer)
# thothnator.p = thothnator.updateP(thothnator.p, question, answer)
# if thothnator.isNeedContinueQ():
# result = ''
# res = {'continue': True, 'result': result}
# else:
# result = thothnator.getBestEstimate()
# thothnator.updateDatabase
# res = {'continue': False, 'result': result}
# return jsonify(res)
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000, debug=True)