general03 / flask-autoindex

Generates index page like mod_autoindex
https://flask-autoindex.readthedocs.io
MIT License
112 stars 35 forks source link

Redirect errors #61

Closed Swanand01 closed 3 years ago

Swanand01 commented 3 years ago

Hi, I currently have a login blueprint at '/' route which redirects the user to '/files'. '/files' should show an index of the ppath directory. However, it is not redirecting. Here is the main app:

app = Flask(__name__)
app.config['UPLOAD_PATH'] = ppath

app.register_blueprint(login)

AutoIndex(app, browse_root=ppath)

@app.route('/files', methods=['GET', 'POST'])
def index():
    if request.method == 'POST':
        uploaded_files = request.files.getlist("file[]")
        for uploaded_file in uploaded_files:
            filename = secure_filename(uploaded_file.filename)
            if filename != '':
                uploaded_file.save(os.path.join(
                    app.config['UPLOAD_PATH'], filename))
    return redirect(url_for('autoindex))

This is the login function at '/'

login = Blueprint('login_bp', __name__)

@login.route('/', methods=['GET','POST'])
def login_interface():
    password = request.form.get('password')
    print(password)
    if password == '1234':
        return redirect('/files')
    return render_template('__autoindex__/login.html')