python - Trouble Routing in Flask -
python - Trouble Routing in Flask -
i have static html file (but 1 in want add together dynamic template variables 1 time working.)
my html file in templates directory.
my flask code looks this:
@restserver.route('/mypage/', methods=['get']) def func(self): homecoming render_template('mypage.html')
i seek opening page in browser going
localhost:5000/mypage
and http 500 error. can please provide insight? thanks.
flask provides automatic redirection non-slash route slash route default ensure there 1 canonical url resource. quoting the docs:
take these 2 rules; @app.route("/projects/")
, @app.route("/about")
though rather similar, differ in utilize of trailing slash in url definition. in first case, canonical url projects endpoint has trailing slash. in sense, similar folder on file system. accessing without trailing slash cause flask redirect canonical url trailing slash.
in sec case, however, url defined without trailing slash, rather pathname of file on unix-like systems. accessing url trailing slash produce 404 “not found” error.
this behavior allows relative urls go on working if trailing slash omitted, consistent how apache , other servers work. also, urls remain unique, helps search engines avoid indexing same page twice.
python flask
Comments
Post a Comment