Skip to content

Instantly share code, notes, and snippets.

@imalsogreg
Created January 12, 2016 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imalsogreg/07dbffac1f1054327db7 to your computer and use it in GitHub Desktop.
Save imalsogreg/07dbffac1f1054327db7 to your computer and use it in GitHub Desktop.
from flask import Flask
import os
import subprocess
from calculation import fullrun
app = Flask(__name__)
okCmds = frozenset(["cowsay","doubleit"])
@app.route('/<cmd>/<arg>')
def runCmd(cmd,arg):
if cmd in okCmds:
o = subprocess.check_output([cmd,arg])
return ('<pre>' + o + '</pre>')
else:
return ( cmd + ' is not an ok command.' )
chem_args = parse(inputBytes) # Bytes
chem_ret_val = fullrun(chem_args) # Data
chem_out = toString(chem_ret_val) # Bytes
@app.route('processData','GET')
def processData():
renderForm
@app.route('processData','POST')
def processData(dataBytes):
bytes = app.getBytes
resp = toString( fullrun ( parse (bytes)))
resp.setHeader('Content-Style','download');
@app.route('/')
def index():
return "Hi"
if __name__ == "__main__":
app.run(host="0.0.0.0", port=8000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment