ThePloki ThePloki - 1 year ago 95
Python Question

How to programmatically create GAE apps (attached to a subdomain)

I have two Flask-based GAE apps. One that is used for the main website that allows users to create their own subdomain of my website, and one that is used for the newly created subdomain.

I would like to know how to do the following:

1) Dynamically create a project app from a form submission (via python)


2) Use a "slug" (obtained from the same form) as a subdomain for that new project (or microservice)

For example:

John Smith fills out the form on the main website, entering his name, email, username, password, and a slug. Let's say he chose "john-smith" as his slug. He is then asked to wait for a few seconds while his Member area is created. Then he is redirected to where he can log in.

I would prefer if these sub-apps were in separate projects so I can monitor billing individually (for each subdomain), but if this is not possible I will be forced to use the microservice (as suggested by BrettJ).

I anticipate hundreds of member sign ups, so I want all of this to happen automatically if possible.

I do not need you to write code for me, I just need some help finding the right direction to go in. Thanks.

Answer Source

What is sounds like you want is to split your app into multiple "services". This doc talks about them as "microservices", but I think that is effectively what you want. Each service has its own app.yaml.

The Flask sample app is composed of two services, which is a front-end and back-end, but shows how to divide your code into multiple "apps" that can be mapped to subdomains based on the routing rules like:

Where "myservice" comes from service: myservice in the app.yaml.

One of the cool things about services is that they don't have to be written in the same language as other services in your project. If you have some code that needs to be in say Go and some in Python, you can divide those into separate services.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download