-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
44 lines (19 loc) · 694 Bytes
/
run.py
File metadata and controls
44 lines (19 loc) · 694 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
# -*- coding:utf-8 -*-
from flask import Flask, render_template, request
from googletrans import Translator, LANGCODES
app = Flask(__name__)
@app.route("/")
def index():
print('index 페이지 입니다.')
return render_template('index.html')
@app.route("/translate", methods=["POST"])
def translate():
text = request.form["text"]
input_lang = request.form["input_lang"]
output_lang = request.form["output_lang"]
translator = Translator()
trans_res = translator.translate(text=text, src=input_lang, dest=output_lang)
trans_text = trans_res.text
return trans_text
if __name__ == '__main__':
app.run(host='127.0.0.1', port='5000')