Search code examples
pythongoogle-app-enginesubdomainwebapp2cname

Dynamic Subdomains with "hello world" application on Google App Engine + webbapp2


I have a few problems. I work and could not figure out for days.

Objective: to create subdomains dynamically on Google App Engine.

I'm just a "hello world" I would like to recommend for implementation, can take care of the rest.

1-http://eqsudmoain.appid.appspot.com written = "eqsubdomain"

2-http://appid.appspot.com written = "hello world"

I want to just do them, I need your help. I find the documentation of this code, but rather than dynamic.

here's code; https://snipt.net/mehmetkose/google-app-engine-dynamic-subdomains-question/?key=7a99428d29d9aa8376158a22dbb63c94

which is also a domain registrar to use the cname Would you recommend? Thank you for your answers.


Solution

  • You can not set domains dynamically in code.

    However you can have different subdomains, by setting different app versions. This how various versions are mapped (note that version is a string not a number):

    http://1.appid.appspot.com   // version "1"
    
    http://eqsudmoain.appid.appspot.com   // version "eqsudmoain"
    
    http://appid.appspot.com   // default version
    

    You can set version in app.yaml. You set default version in Admin - Versions.

    So, what you propose is possible, by uploading code multiple times under different versions, then using example code in the link to distinguish between subdomains in code.

    Edit:

    You can not have dynamic subdomain mapping on *.appid.appspot.com, but you can have wildcard DNS mapping on your own domain, i.e. *.yourdomain.com. Then in code you can check the host and and route request to the right code.