running mutliple flask application

  • Posted on February 20, 2015
  • HamoudAsked by Hamoud

Hello there , i have followed the tutorial here : , that is about how to deploy flask app on ubuntu and it works with me pretty fine.

but i’m wonder how to run multiple apps at the same time. when i enabled the virtual host the default one ( index.html for example diapered ) i want to give each application home directory like /var/www/App1 thus if my App1 route “/about” it will be

i came from webfaction and i was familiar with the way the handle many applications at same host

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

If the two Flask apps are running on the same domain just as subfolders, then you only need one VirtualHost but you’ll need multiple WSGIScriptAlias directives. Using the set up from the tutorial you linked as a base, your Apache configuration would look something like this:

WSGIPythonPath /var/www/FirstFlaskApp:/var/www/SecondFlaskApp

<VirtualHost *:80>

    WSGIScriptAlias /FirstFlaskApp /var/www/FirstFlaskApp/flaskapp.wsgi
    <Directory /var/www/FlaskApp/FlaskApp/>
            Order allow,deny
            Allow from all

    Alias /FirstFlaskApp/static /var/www/FirstFlaskApp/FirstFlaskApp/static
    <Directory /var/www/FirstFlaskApp/FirstFlaskApp/static/>
            Order allow,deny
            Allow from all

    WSGIScriptAlias /SecondFlaskApp /var/www/SecondFlaskApp/flaskapp.wsgi
    <Directory /var/www/FlaskApp/FlaskApp/>
            Order allow,deny
            Allow from all

    Alias /SecondFlaskApp/static /var/www/SecondFlaskApp/SecondFlaskApp/static
    <Directory /var/www/SecondFlaskApp/SecondFlaskApp/static/>
            Order allow,deny
            Allow from all

    ErrorLog ${APACHE_LOG_DIR}/error.log
    LogLevel warn
    CustomLog ${APACHE_LOG_DIR}/access.log combined

With a directory structure like this:

├── FirstFlaskApp
│   ├── FirstFlaskApp
│   │   ├──
│   │   ├── __init__.pyc
│   │   ├── static
│   │   └── templates
│   └── flaskapp.wsgi
└── SecondFlaskApp
    ├── flaskapp.wsgi
    └── SecondFlaskApp
        ├── __init__.pyc
        ├── static
        └── templates

How the virtualhost will look like if each of the apps would have different domain names? Apache is not allowing two virtualhosts listening on the same port Number.

This comment has been deleted