开发者

Google AppEngine custom 404 dynamic page

开发者 https://www.devze.com 2023-02-19 02:57 出处:网络
I want to set custom 404 page and admin zone in /dev/ path , so I have this app.yaml: application: appengine_app

I want to set custom 404 page and admin zone in /dev/ path , so I have this app.yaml:

application: appengine_app
version: 0-00-1
runtime: python
api_version: 1

handlers:    

- url: /dev/.*
  script: dispatch.py
  login: admin

- url: /.*
  script: dispatch.py

with next code

app = webapp.WSGIApplication( [ ('/dev/analyze', AnalyzePage)
                              , ('/.*', NotFoundPage) ]
                              , debug=False )

On local machine all is ok. But when I try to GET /dev/analyze on Production server it redirects to /_ah/login_required?continue=http://appengine_app.appspot.com/dev/analyze and it catched by NotFoundPage. So I can not use admin part on Production. Can I has dynamic 404 page and admin part of site?

UPD: if I switch off NotFoundPage and try to GET /dev/analyze on Production server it redirects to /_ah/login_required?cont开发者_JS百科inue=http://appengine_app.appspot.com/dev/analyze and response with 404 error


You've set the script handle in app.yaml to admin-only, which means the runtime will ensure you're logged in as an admin before it sends requests to your code. There's no way for the runtime to know that the page will result in a 404 - and this is plausibly something you may not even want non-admin users to discover.

If it's important that you send 404s to users who aren't signed in, you can either make the handler in app.yaml more specific - eg, make it match only /dev/analyze - or you can shift the admin check into your code.

0

精彩评论

暂无评论...
验证码 换一张
取 消