Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect errors #61

Closed
Swanand01 opened this issue Jun 23, 2021 · 0 comments
Closed

Redirect errors #61

Swanand01 opened this issue Jun 23, 2021 · 0 comments

Comments

@Swanand01
Copy link

Swanand01 commented Jun 23, 2021

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')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant