Setting a custom url scheme in appengine using app.yaml?

I am trying to create my own url that looks like this:

example.com/site/yahoo.com

which would hit this script as follows:

example.com/details?domain=yahoo.com

Can this be done using app.yaml?

The basic idea is to call up "details" with the input "yahoo.com"

+3
source share
1 answer

You really cannot rewrite URLs as such, but you can use regex groups to do this.

In the app.yaml file try something like:

handlers:
- url: /site/(.+)
  script: site.py

And on your site.py site:

SiteHandler(webapp.RequestHandler):
    def get(self, site):
        # the site parameter will be what was passed in the URL!
        pass

def main():
    application = webapp.WSGIApplication([('/site/(.+)', SiteHandler)], debug=True)
    util.run_wsgi_app(application)

, , /site/ URL- , SiteHandler get() site. , /details?domain=yahoo.com, URL.

+4

Source: https://habr.com/ru/post/1749156/


All Articles