You are not logged in.

#1 26-08-2017 15:03:03

Registered: 19-10-2011
Posts: 26

Love alwaysdata - but I'm a bit lost

Could you make a small blog post explaining how to setup a minimal, super simple, hello world WSGI flask app using virtualenv and the virtualenvwrapper. I had about 4-5 small flask apps working great on AD, but all of them where using the FCGI setup with eval pointing to my modules directory:

#!/usr/bin/eval PYTHONPATH=/home/freethrow/modules python

from flup.server.fcgi import WSGIServer
from flask import Flask
from vasilisa import create_app, db
import os

#application = create_app(os.getenv('FLASK_CONFIG') or 'default')
application = create_app('development')

class ScriptNameStripper(object):
    def __init__(self, app): = app
    def __call__(self, environ, start_response):
        environ['SCRIPT_NAME'] = ''
        return, start_response)

application.wsgi_app = ScriptNameStripper(application.wsgi_app)

if __name__ == '__main__':

I would love to switch to the wsgi type of setup instead of "chasing" modules in the modules directory. If I understand correctly, currently one of my small sites ( doesn't work because it cannot find the Pillow (python imaging library) module.

If I get this correctly, I should choose python 2.7 as the default python version:

1) install virtualenv and virtualenvwrapper  - how do I export the path for the command mkvirtualenv to be used?
2) make a new virtualenv with all the pip requirements dependencies
3) upload my app in a directory
4) fill out all of the data
adresses : (par exemple) - this is my site url, i.e.
type : Python WSGI
chemin de l'application : /myapp/myapp/
répertoire de travail : /myapp/
répertoire du virtualenv : /myenv/
chemins statiques : /static/=/my_static_directory/

Thank you.

edit: I was able to export virtualenvwrapper with . /home/freethrow/.local/bin/" >> .bash_profile
. All I would need at this point is an exapmple wsgi file, analog to the flup one.

Last edited by freethrow (26-08-2017 15:26:42)


#2 28-08-2017 09:43:57

Registered: 03-03-2016
Posts: 243

Re: Love alwaysdata - but I'm a bit lost


The point to understand is that now, libraries like Django, Flask or Pillow, are no longer preinstalled on our server. Our clients need to install them on their own account now.

To make tests with the WSGI type before using it for your production websites, you can certainly use the address of your account:

Once you will done it, if you want to create an documentation article on how create a simple Flask project, on our help it would be a pleasure to correct and publish it.


#3 28-08-2017 10:28:39

From: Paris
Registered: 06-02-2007
Posts: 5,608

Re: Love alwaysdata - but I'm a bit lost

I assume you have selected the 2.7.13 Python version in Environment > Python. Let's create our virtualenv, a mini-application (I took the one from Flask's homepage), and the required WSGI file:

foobar@ssh2:~$ virtualenv env
New python executable in /home/foobar/env/bin/python
Installing setuptools, pip, wheel...done.
foobar@ssh2:~$ ./env/bin/pip install Flask
Collecting Flask
  Using cached Flask-0.12.2-py2.py3-none-any.whl
Collecting click>=2.0 (from Flask)
  Using cached click-6.7-py2.py3-none-any.whl
Collecting Werkzeug>=0.7 (from Flask)
  Using cached Werkzeug-0.12.2-py2.py3-none-any.whl
Collecting Jinja2>=2.4 (from Flask)
  Using cached Jinja2-2.9.6-py2.py3-none-any.whl
Collecting itsdangerous>=0.21 (from Flask)
  Using cached itsdangerous-0.24.tar.gz
Collecting MarkupSafe>=0.23 (from Jinja2>=2.4->Flask)
  Using cached MarkupSafe-1.0.tar.gz
Building wheels for collected packages: itsdangerous, MarkupSafe
  Running bdist_wheel for itsdangerous ... done
  Stored in directory: /home/foobar/.cache/pip/wheels/fc/a8/66/24d655233c757e178d45dea2de22a04c6d92766abfb741129a
  Running bdist_wheel for MarkupSafe ... done
  Stored in directory: /home/foobar/.cache/pip/wheels/88/a7/30/e39a54a87bcbe25308fa3ca64e8ddc75d9b3e5afa21ee32d57
Successfully built itsdangerous MarkupSafe
Installing collected packages: click, Werkzeug, MarkupSafe, Jinja2, itsdangerous, Flask
Successfully installed Flask-0.12.2 Jinja2-2.9.6 MarkupSafe-1.0 Werkzeug-0.12.2 click-6.7 itsdangerous-0.24
foobar@ssh2:~$ mkdir myapp
foobar@ssh2:~$ cd myapp/
foobar@ssh2:~/myapp$ cat > <<EOF
from flask import Flask
app = Flask(__name__)

def hello():
    return "Hello World!"

foobar@ssh2:~/myapp$ cat > <<EOF
from app import app as application

Now create a new site (in the Web > Sites) section, with:

- application path: /myapp/
- virtualenv directory: /env/

That's it smile


#4 28-08-2017 22:56:03

Registered: 19-10-2011
Posts: 26

Re: Love alwaysdata - but I'm a bit lost

Thank you, Cyril you re the man!


#5 06-02-2018 19:37:18

Registered: 28-01-2018
Posts: 4

Re: Love alwaysdata - but I'm a bit lost

I also encountered the problem to start with flask here, and I am very pleased to have found finally this ticket. Extremely helpful! Thanks Cyril for your response!


Board footer

Powered by FluxBB