Question

I'm creating admin panel for my GAE application.

Here is part of my app.yaml

- url: /admin/.*
  script: admin.application
  login: admin

- url: /.*
  script: myApp.application

And Here is part of my my admin.py:

class AdminPage(webapp2.RequestHandler):
    def get(self):
        self.response.headers['Content-Type'] = 'text/plain'
        self.response.write('Hello, Admin')

application = webapp2.WSGIApplication([
    ('/', AdminPage),
], debug=True)

If I'm not logged in I get "Current logged in user test@example.com is not authorized to view this page." message, which is what I wanted.

I get 404 error when I try to go to myApp/admin/ while logged in as admin and I don't know how to solve this.

Était-ce utile?

La solution

It looks like your application doesn't have a rule for /admin/. You'll need to change your application to this:

application = webapp2.WSGIApplication([
    ('/admin/', AdminPage),
], debug=True)

When you go to /admin/, the login: admin part of your app.yaml shows the login error before it ever hits your admin.py file if you're not logged in. When you are logged in, the application tries to find a url matching /admin/, but the only configured url is /.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top