Created
March 22, 2018 05:17
-
-
Save viveksb007/63000de701487e762ee2c170f309342f 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
from flask import Flask, request, redirect, url_for, render_template, send_from_directory | |
from werkzeug.utils import secure_filename | |
@app.route('/', methods=['GET', 'POST']) | |
def index(): | |
if request.method == 'POST': | |
if 'file' not in request.files: | |
print('No file attached in request') | |
return redirect(request.url) | |
file = request.files['file'] | |
if file.filename == '': | |
print('No file selected') | |
return redirect(request.url) | |
if file and allowed_file(file.filename): | |
filename = secure_filename(file.filename) | |
file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) | |
process_file(os.path.join(app.config['UPLOAD_FOLDER'], filename), filename) | |
return redirect(url_for('uploaded_file', filename=filename)) | |
return render_template('index.html') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment