B
B
Bleno2020-05-26 20:57:41
Python
Bleno, 2020-05-26 20:57:41

How to do dynamic subdomain handling on flask?

Let the domain be domain.com

I have a web server on flask located at localhost:8080.
There is also nginx.

The whole thing is hidden under cloudflare and works great, but I need users to be able to add their own pages like page.domain.com, and at the same time flask handles it adequately. Googling, I found out that flask can do this:

@app.route('/somepage', subdomain='<subdomain>')
def handler(subdomain):
...

I tried, but the requests do not go through (well, that is, the page is simply not available in the browser). I also tried adding the following to the nginx config:
server {
    listen 80;
    server_name *.domain.com;

    location / {
        proxy_pass http://localhost:8080;
    }
}


But still to no avail. I hope for your help...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dimonchik, 2020-05-27
@dimonchik2013

https://stackoverflow.com/questions/7512698/flask-...
see about hosts there

K
Konstantin Velichko, 2014-04-22
@Zoxon

Looks like Futura and pragmatics condensed bold

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question