Forums

405 Method not Alllowed in Flask

views.py

@app.route('/make', methods=['POST', 'GET'])
def send_request():
    form = ApplyForm()
    if request.method == 'POST':
        dr = dr
        db.session.add(dr)
        db.session.commit()
        return render_template(
            's.html',
            title='Success',
        )
    else:
        return render_template(
            'make.html',
            title='Make Request',
            form=form
       )

make.html

<form action="" method="post">
    <label>Gender {{ form.gender }}</label></br>
    <div class="controls">
        <input class="btn btn-primary" type="submit" value="Apply Now">
    </div>
</form>

When I click submit button in make.html it redirects to 405 Method not Allowed although I have in views.py this:

@app.route('/make', methods=['POST', 'GET'])

How to resolve this problem? This only happens at the server pythonanywhere, at localhost all is OK.

It looks like you have the wrong action on your form -- if it's meant to be routing to that view, it should say

<form action="/make" method="post">