Hackr.io is hiring Software Developers. Email us your CV on hr@hackr.io

Flask Discussion Forums

There's no such thing as a stupid question. Ask. Discuss. Learn.

Flask Error: “Method Not Allowed The method is not allowed for the requested URL”

@app.route('/index',methods=['GET', 'POST'])
@login_required
def index():
form=PredictForm()
fig=plt.figure(figsize=(6,6))

ax=fig.add_axes([0.2,0.2,0.6,0.6])
ax.imshow(plt.imread(we_fig))
plt.title('WeChat Public Number:Quant0532',color='red')
eraseFrame(ax)
tmp=BytesIO()
fig.savefig(tmp,format='png')
form.fig=base64.encodebytes(tmp.getvalue()).decode()

if form.validate_on_submit():
return redirect(url_for('index'))
return render_template('index.html', title='Home', form=form)

above code runs well but when I change the second line from bottom to be "return render_template('index.html', title='Home', form=form)", it can't work and raise the error: "Method Not Allowed The method is not allowed for the requested URL"; and in real, I really need to use the changed code for passing parameters.
Frank 6 months ago
  • Whitelisted Links
;