Routing fade modal in flask
I am having an issue with my fading modal routing in flask. My user login opens a modal and im trying to implement the POST feature from the modal in flask.
I thought of implementing under index and search for the form name form the the post like below.
@app.route('/')
@app.route('/index')
def index():
if request.form.get('login', None) == 'submit' :
return 'Yeah hooo'
return render_template('index.html')
However, when i execute the code above, i get
Method Not Allowed
on /index. My other worries is that my Login form is in the template and can therefore be call from any routes. Since template is not a route. Please is there any way i can achieve this in flask ? Or do i have to take the login in to a seperate html file instead of the template ?
You should explicitly add POST to the list of methods that can be processed
@app.route('/', methods=['GET', 'POST'])
See here for more information
As per the second question, it's ok as long as your login form makes POST request to the same route ( '/'
in your case).
上一篇: 为href没有响应
下一篇: 烧瓶中的路由淡入淡出模式