Spaces:
Running
Running
from flask import Flask,request,render_template | |
import os | |
app=Flask(__name__) | |
MESSAGED={'title':'Script Server', | |
'messageL':['script in "script" parameter or field of json input to /run will be run']} | |
def run_script(): | |
script='' | |
# print(request.method) | |
print(request) | |
if request.method=='GET': | |
script=request.args.get('script') | |
print('I am in get') | |
elif request.method=='POST': | |
print('I am in post') | |
data=request.get_json() | |
if 'script' in data: script=data['script'] | |
if script=='' or script is None: return 'INVALID' | |
os.system(script+' > ./out.txt') | |
with open('./out.txt','r') as f: output=f.read() | |
return output | |
def home(): | |
return render_template('home.html',messageD=MESSAGED) | |
if __name__=='__main__': | |
app.run() | |