The Simple Hosting Python instance enables you to publish web applications written in Python easily and affordably.


  • Familiarity with the Python coding language and WSGI protocol
  • Your application must have a WSGI entry point
  • You must be familiar with Git

Version support

When creating a new Python instance, you currently have two options :

  • 2.7 (includes 3.2 support)
  • 3.6

If you’ve selected a Python 2.7 instance, to choose the version that you want to use in order to run your application, see “Python Version Selection” below.

Basic Use

Your Python app must contain at least one file named, which itself must contain the application object, in accordance with the PEP agreement specified here:


A domain name is made available for testing purposes when the instance is created. You can link a number of domain names and subdomains. All will point to the same application code base.


Directory layout


def application(environ, start_response):
    start_response('200 OK', [('Content-Type', 'text/html; charset=utf-8')])
    return ['<!DOCTYPE html><html><meta charset="utf-8"><title>It works',
            '</title><h1>It works!</h1>']

Application dependencies

Your application’s dependencies have to be installable with pip, and must be specified in a file named requirements.txt.

For the dependencies to be automatically installed, you need to deploy the code with Git.

As you develop your application on a local machine, install the dependencies with pip install. Then, when your application is ready to go into production, run the following command locally to generate a file containing all the dependencies:

$ pip freeze > requirements.txt

This command will populate the requirements.txt file with modules and dependencies based on those you have installed on your development environment. You must use Git to commit and push this file to the instance for it to be used. The dependencies will be installed when you deploy the application with SSH.

For more information, see:

For more information on deploying your application with git+SSH, checkout out git guide.

Python version selection


This section only applies to Python 2.7 / 3.2 instances.

It is possible to choose the version of Python that you want to use to execute your application from the available versions we offer. To do this, you will need to specify the Python version that you want to use in a gandi.yml file at the root of your project, in the python field:


  version: 3.2

The above example will force the usage of Python 3.2. If the file exists but there is no python field, or in the event that the yaml format is invalid, the default version will be used. If an invalid value is specified, your application will not boot and an error message will be displayed in the deployment logs of your application and in the boot logs of your instance.


This file, as every other files composing your project, needs to be tracked by Git and pushed to your Simple Hosting remote repository before issuing the deploy command.

Static Files

Place all of your static content in directories named /static/ or /media/, so that the Apache HTTPD server can pick them up.


The standard error output from your application will be written to the following files on your instance’s disk:

  • from the SSH console: /srv/data/var/log/www/uwsgi.log
  • over SFTP: /lamp0/var/log/www/uwsgi.log

You can use these files to monitor the successful start of your application.

You also have the option of configuring the logger to fit your needs. Add a file called logging.ini to the project’s root to do so.

For more information, see:


An example Flask application

Directory layout

├── requirements.txt
├── static/
├── templates/

from minitwit import app as application



A Django example

Directory layout

├── media/
├── cms/
│   ├──
│   └── cms/
│       ├──
│       ├──
│       ├── templates/
│       └──
├── requirements.txt
├── static/

import sys
import os
import os.path

sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__),
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'cms.settings')
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()



Character encoding

To enable special character support in uwsgi, for example within filenames, add the following statements to the file: