-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
28 lines (22 loc) · 697 Bytes
/
main.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
from flask import Flask, request, jsonify,render_template
import os
from flask_cors import CORS, cross_origin
from translator import translation
#predict(text)
os.putenv('LANG', 'en_US.UTF-8')
os.putenv('LC_ALL', 'en_US.UTF-8')
app = Flask(__name__)
CORS(app)
@app.route("/predict", methods=['POST'])
@cross_origin()
def predictRoute():
text = request.json["text"]
trans = translation(text)
result = trans.translate_word()
print(result)
print(type(result))
return {"Result": str(result)}
#port = int(os.getenv("PORT"))
if __name__ == "__main__":
#app.run(host='0.0.0.0', port=port)
app.run(host='127.0.0.1', port=8000, debug=True)