Created
October 31, 2016 17:59
-
-
Save di/35c7f08f27af97bbe997f2f288e9e216 to your computer and use it in GitHub Desktop.
simple flask server which receives files and stores them locally
This file contains 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
import os | |
from flask import Flask, request | |
from werkzeug.utils import secure_filename | |
app = Flask(__name__) | |
app.config['UPLOAD_FOLDER'] = '.' | |
@app.route('/', methods=['POST']) | |
def upload_file(): | |
file = request.files['filedata'] | |
if file: | |
filename = secure_filename(file.filename) | |
file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) | |
return 'it worked' | |
return 'no file' | |
@app.route('/', methods=['GET']) | |
def index(): | |
return 'it works' | |
if __name__ == '__main__': | |
app.run('0.0.0.0', port=80, debug=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment