Created
July 28, 2014 16:22
-
-
Save vrootic/23c35174bcc854f388b1 to your computer and use it in GitHub Desktop.
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 render_template, request, send_from_directory | |
from werkzeug.utils import secure_filename | |
from app import app | |
@app.route('/') | |
def index(): | |
return render_template('index.html') | |
@app.route('/upload', methods=['GET', 'POST']) | |
def upload_file(): | |
if request.method == 'POST': | |
file = request.files['file'] | |
if file.filename: | |
filename = secure_filename(file.filename) | |
file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) | |
return render_template('index.html', filename=filename) | |
return render_template('index.html') | |
@app.route('/uploads/<path:filename>') | |
def uploaded_file(filename): | |
return send_from_directory(app.config['UPLOAD_FOLDER'], filename, as_attachment=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment