forked from ekpraveen123/RobocarApp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
43 lines (29 loc) · 1.19 KB
/
main.py
File metadata and controls
43 lines (29 loc) · 1.19 KB
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
36
37
38
39
40
41
42
43
from flask import Flask, flash, redirect, render_template,request,Response,session
from subprocess import Popen,PIPE
app = Flask(__name__)
@app.route("/")
def hello():
return render_template('first.html')
@app.route("/runInitScripts")
def runScripts():
dirpath = request.values.get("dir")
print dirpath
def inner():
cmd = ["scripts/test.sh"]
proc = Popen(cmd,stdout=PIPE,stderr=PIPE,stdin=PIPE)
for line in iter(proc.stdout.readline,''):
yield line.rstrip() + '<br/>\n'
return Response(inner(), mimetype='text/html')
@app.route("/train")
def train():
def inner():
proc = Popen(
["processes/train.py"], #call something with a lot of output so we can see it
shell=True,
stdout=PIPE
)
for line in iter(proc.stdout.readline,''):
yield line.rstrip() + '<br/>\n'
return Response(inner(), mimetype='text/html') # text/html is required for most browsers to show th$
if __name__ == "__main__":
app.run(host='0.0.0.0',port=8080)