Created
January 12, 2016 21:10
-
-
Save imalsogreg/07dbffac1f1054327db7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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