-
Notifications
You must be signed in to change notification settings - Fork 1
/
flask3.py
34 lines (29 loc) · 845 Bytes
/
flask3.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
29
30
31
32
33
34
from flask import Flask, redirect, url_for, request
app = Flask(__name__)
@app.route('/success/<name>')
def success(name):
return 'Sentences-> %s' % name
@app.route('/login',methods = ['POST', 'GET'])
def login():
if request.method == 'POST':
s1 = request.form['sent1']
s2 = request.form['sent2']
s3 = s1 + "\n" + s2
if s1 and s2:
write2file(s1, s2)
print s1, s2
return redirect(url_for('success',name = s3))
else:
user = request.args.get('nm')
return redirect(url_for('success',name = user))
def write2file(S1, S2):
text = "python sts1.py \"" + S1 + "\" \"" + S2 + " \""
open('script.sh', 'w').close()
f = open('script.sh', 'w')
f.write(text)
f.close()
print "Done Writing"
from subprocess import call
call(['sh', 'script.sh'])
if __name__ == '__main__':
app.run(debug = True)