-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.py
31 lines (30 loc) · 983 Bytes
/
server.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
from flask import Flask,request,render_template
from interpreter import *
app = Flask(__name__)
@app.route('/',methods=["GET","POST"])
def gfg():
if request.method=="POST":
script=request.form.get('code')
Input=request.form.get('input')
flags=request.form.get('flags')
if Input:
Input=[eval(i) for i in Input.split("\n")]
else:
Input=[]
data=execute(script,[''],Input,[*flags])
fine="".join(data[0])
l=str(len(script))
leng=l+' bytes, '+l+' chars, (SBCS)'
send="\n".join(map(str,Input))
if send=='pass':
send=''
debug=request.form.get('debug')
transpiled="".join(data[1])
if debug:
fine+="\n"
fine+="=====================================\n"
fine+=transpiled
return render_template('index.html',output=fine,code=script,leng=leng,input=send,trans=transpiled,elapsed=data[2])
return render_template("index.html")
if __name__=='__main__':
app.run(port=7777,debug=True)