Example Address: http://docs.jinkan.org/docs/flask/views.html
The author wrote a test example according to the document, in the browser access http://127.0.0.1:5000/user/error: If Self.url_rule and '. ' In Self.url_rule.endpoint.
The test example code is as follows:
flask
render_templateView app = Flask (
__name__)
Showusers (View):
dispatch_request (self):
render_template (' test.html ')
App.add_url_rule ('/user/', Showusers.as_view (' show_users '))
__name__ = = ' __main__ ':
app.run ( )
Workaround:
According to the error information, view app.add_url_rule related documents, parameters endpoint general and view function names are the same, the code is modified as follows:
flask
render_templateView app = Flask (
__name__)
Showusers (View):
dispatch_request (self):
render_template (' test.html ')
App.add_url_rule ('/user/', ' show_users ', Showusers.as_view (' show_users '))
__name__ = = ' __main__ ':
App.run ()
http://127.0.0.1:5000/user/is normal in browser access.