0

I have built a flask application that will be used by restaurants, I want to know how I can make the app give each restaurant a subdomain and own database when they register for an account on our landing page.

1 Answers1

0

This question sounds like it is more about the Domain Name System than Flask.

You're saying that your server will start running, and then days or weeks later a new client will register with some new restaurant_name, e.g. "spicytacos". You would like to create a new spicytacos.example.com FQDN in the Domain Name System, with A or AAAA record pointing at your webserver. Then your flask app will be able to recognize the restaurant's name in request.args and respond appropriately.

If you're running the primary nameserver of example.com with BIND9 or similar, then it's just a matter of re-writing the zone config file and sending a HUP signal.

If you prefer to let some other firm handle nameservice details, then probably a * wildcard record is your best bet. It should be a CNAME or address record pointing to your server.

A middle path would be to use a DDNS (dynamic DNS) service, perhaps from afraid.org or No-IP. That is another way of binding a FQDN to an address, which gives you a little more control.

Please refer to How to create dynamic subdomains in a Flask application to see how @app.before_request can parse out novel hostnames during request routing.

J_H
  • 17,926
  • 4
  • 24
  • 44
  • Thanks a lot...i'd like my app to do it for me (not me going on AWS to create a subdomain and clone the whole app there) but let me try what you suggested and will let you know if it works! – SAMUEL Tuyizere Feb 24 '19 at 23:55