-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapplication.py
More file actions
34 lines (25 loc) · 910 Bytes
/
application.py
File metadata and controls
34 lines (25 loc) · 910 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
import inference
from flask import Flask, request, render_template
from flask_cors import CORS
application = Flask(__name__)
CORS(application) # apply CORS on all routes
@application.route("/")
def hello():
return "Hello JEJU!"
@application.route("/translation", methods=["GET", "POST"])
def translation():
form_data = request.get_json()
response = {}
if request.method == "POST":
text = form_data["text"]
if form_data["button"] == "s2d":
answer = inference.s2d(text)
response["result_text"]= answer
return response
if form_data["button"] == "d2s":
answer = inference.d2s(text)
response["result_text"]= answer
return response
return render_template("testpage.html", title="testpage")
if __name__ == "__main__":
application.run(host='0.0.0.0', port=5000, threaded=True)