-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
27 lines (19 loc) · 776 Bytes
/
app.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
from flask import Flask, render_template, request
import subprocess
app = Flask(__name__)
@app.route('/', methods=['GET', 'POST'])
def index():
if request.method == 'POST':
sentence = request.form['sentence']
if sentence:
# Construct the command
command = ["python3", "pages/model/inference.py", "--text", sentence, "-l", "te"]
# Run the command
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
# Capture the output and error messages
output, error = process.communicate()
# Return the output directly
return output.decode()
return render_template('index.html')
if __name__ == '__main__':
app.run(debug=True)