-
-
Save brianherman/6017054 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 cStringIO | |
app = Flask(__name__) | |
import string | |
@app.route('/k/', methods=['POST']) | |
def work_with_data(): | |
print request.form # here's post data in a dict - do what you will... | |
f = open(name, 'w') | |
output = cStringIO.StringIO() | |
output.write('First line.\n') | |
output.write(f.getvalue()); | |
import subprocess | |
process = subprocess.Popen(["emcc", name], stdout=subprocess.PIPE) | |
result = process.communicate()[0] | |
return result | |
@app.route('/run/', methods=['GET']) | |
def run_with_data(): | |
print request.form # here's post data in a dict - do what you will... | |
f = open('workfile', 'r') | |
output = cStringIO.StringIO() | |
output.write('<html>\n<script>') | |
output.write(f.getvalue()); | |
# Retrieve file contents -- this will be | |
# 'First line.\nSecond line.\n' | |
contents = output.getvalue() | |
# Close object and discard memory buffer -- | |
# .getvalue() will now raise an exception. | |
output.write("</script></html>") | |
output.close() | |
return contents | |
if __name__ == '__main__': | |
app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment