-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
35 lines (30 loc) · 856 Bytes
/
Copy pathserver.py
File metadata and controls
35 lines (30 loc) · 856 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
31
32
33
34
35
import random
import string
from urllib import response
import flask
from flask import jsonify, request
from eva.nlp import NLP
from eva.oracle import Oracle
from eva.wiki_search import generate_wiki_page
app = flask.Flask(__name__)
app.config["DEBUG"] = True
@app.route('/sanity', methods=['GET'])
def check_sanity():
response = jsonify({
"status": "ok"
})
response.status_code = 200
return response
@app.route('/question', methods=['POST'])
def question():
question_contents = request.get_json()
generate_wiki_page(question_contents["question_text"])
with open('paragraph.txt', 'r', encoding="utf-8") as f:
paragraph = f.read()
oracle = Oracle(question_contents, paragraph)
answer= jsonify({
"answer": oracle.answer()
})
answer.status_code=200
return answer
app.run(port=3000)