-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
37 lines (29 loc) · 1.02 KB
/
main.py
File metadata and controls
37 lines (29 loc) · 1.02 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
from flask import Flask, render_template
from flask_bootstrap import Bootstrap
from flask_wtf import FlaskForm
from wtforms import StringField, SubmitField
from wtforms.fields.html5 import IntegerField
from wtforms.validators import DataRequired
import os
SECRET_KEY = os.urandom(32)
import subprocess
app=Flask(__name__)
bootstrap=Bootstrap(app)
app.config['SECRET_KEY'] = SECRET_KEY
class InputForm(FlaskForm):
first=IntegerField('',validators=[DataRequired()])
superscript=IntegerField('',validators=[DataRequired()])
submit=SubmitField('Submit')
@app.route('/',methods=['GET','POST'])
def index():
form=InputForm()
if form.is_submitted():
first=form.first.data
superscript=form.superscript.data
process=subprocess.run(["./main",first,superscript],capture_output=True)
string=process.CompletedProcess.stdout
return render_template("index.html",form=form,string=string)
else:
return render_template("index.html",form=form)
if __name__=='__main__':
app.run()