Skip to content

Instantly share code, notes, and snippets.

@thamizhchelvan
Created December 29, 2017 03:33
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 thamizhchelvan/05c635ca0ed9f8b3b28c2665adeee986 to your computer and use it in GitHub Desktop.
Save thamizhchelvan/05c635ca0ed9f8b3b28c2665adeee986 to your computer and use it in GitHub Desktop.
The server code
import os
from flask import Flask, request, render_template, url_for, redirect
app = Flask(__name__)
@app.route("/")
def fileFrontPage():
return render_template('fileform.html')
@app.route("/handleUpload", methods=['POST'])
def handleFileUpload():
if 'photo' in request.files:
photo = request.files['photo']
if photo.filename != '':
photo.save(os.path.join('C:/Users/Public/Pictures', photo.filename))
return redirect(url_for('fileFrontPage'))
if __name__ == '__main__':
app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment