Problem with setup of subdomains in flask

February 3, 2016 971 views
Python Python Frameworks

I am trying to setup flask blueprints with subdomains. However it doesnt work.
i have setup my domain to point to the digitalocean dns servers.
I made a created an A record, with @ so i assume that it should cover everything behind the

my sample testfile is

from flask import Flask, Blueprint
app = Flask(__name__)
app.config['SERVER_NAME'] = ''

test = Blueprint('test', __name__)
def testindex():
    return "This is test index page."

app.register_blueprint(test, subdomain='sub')

as described here

however the result is always ERRNAMENOT_RESOLVED.

Anybody have an idea of what im doing wrong?

1 Answer

ERR_NAME_NOT_RESOLVED means the domain name you typed in your address bar couldn't be resolved to an IP address. Without knowing the domain name, there's very little that can be done to help.

  • okay, thank you. The domain is, and it works fine with blueprints if i dont use the subdomain part.

    • Hi,

      I really can't say anything without the actual, full domain. Your domain works just fine. Are you sure you created the A record?

      EDIT: Even though this isn't likely to be the problem, have you tried clearing your DNS cache if your computer has one?

      • Thanks for the answer.
        Sorry for my ignorance, but what do you mean by the full domain?
        So i have, (which is my maindomain) it is setup as A record, with @ pointing towards my ip The idea is then to have subdomains towards

        I have tried two different computers for the same reason.

        • The only thing you need to do is create an A record named that points to the correct IP and it will work. Presumably you've done this, but I have no clue what example is in your case so other than telling you to create the A record correctly, there isn't much I can suggest. is what I mean by the full domain, so that I could actually verify if it resolves on my side.

          • thanks, that was my problem, i didnt have an A record, i thought my @ was enough. Now it works.
            Is there any way of making it dynamic, so i dont have to make all the A records, and put everything in the conf file:
            <VirtualHost *:80>
            WSGIScriptAlias / /var/www/omicsdb/flaskapp.wsgi
            <Directory /var/www/Flaskapp/app/>
            Order allow,deny
            Allow from all
            Alias /static /var/www/omicsdb/app/static
            <Directory /var/www/FlaskApp/app/static/>
            Order allow,deny
            Allow from all
            ErrorLog ${APACHELOGDIR}/error.log
            LogLevel warn
            CustomLog ${APACHELOGDIR}/access.log combined

Have another answer? Share your knowledge.