Answer the question
In order to leave comments, you need to log in
Why does sending a POST request to flask redirect me to fu.Php?
in general, there is such a code
import os
from app import app
from flask import Flask,render_template,request,flash,redirect,url_for
from config import Configurations
from werkzeug.utils import secure_filename
app.secret_key = b'hul'
@app.route('/dz',methods=['GET','POST'])
def index():
error = None
if request.method == 'POST':
if 'file' not in request.files:
error = 'слышь,файл выбери!'
#return redirect(request.url)
file = request.files['file']
# if user does not select file, browser also
# submit an empty part without filename
if file.filename == '':
error = 'слышь,файл выбери!'
#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))
#return redirect(url_for('uploaded_file',
# filename=filename))
return render_template('index.html',error = error)
return render_template('index.html')
<!doctype html>
<title>Upload new File</title>
<h1>Upload new File</h1>
<form method=post enctype=multipart/form-data>
<input type=file name=file>
<input type=submit value=Upload>
</form>
{{ error }}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question