Skip to content

Instantly share code, notes, and snippets.

@nishio

nishio/server.py Secret

Created May 27, 2014 08:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nishio/be5b5071a8c8fb94836b to your computer and use it in GitHub Desktop.
Save nishio/be5b5071a8c8fb94836b to your computer and use it in GitHub Desktop.
server.py
from flask import Flask, request, send_from_directory
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'ok' # TODO: show index
@app.route('/collecting/<path:filename>')
def send_foo(filename):
print filename
return send_from_directory('../collecting', filename)
@app.route('/api/save/<filename>', methods=['POST'])
def save(filename):
print filename
print request.form['data']
file(filename, 'w').write(request.form['data'])
return 'ok'
if __name__ == '__main__':
app.run(debug=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment