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
When creating a new Python instance, you currently have four options :
- 2.7 (includes 3.2 support)
If you’ve selected a Python 2.7 instance, to switch between 2.7 and 3.2 in order to run your application, see “Python Version Selection” below.
Your Python app must contain at least one file named wsgi.py, which itself must contain the application object, in accordance with the PEP agreement specified here: http://www.python.org/dev/peps/pep-0333/#the-application-framework-side
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.
Your application’s dependencies have to be installable with
pip, and must be specified in a file named
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.
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: 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.
Place all of your static content in directories named
/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:
- over SFTP:
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:
. ├── minitwit.py ├── requirements.txt ├── static/ ├── templates/ └── wsgi.py
from minitwit import app as application
. ├── media/ ├── cms/ │ ├── manage.py │ └── cms/ │ ├── init.py │ ├── settings.py │ ├── templates/ │ └── urls.py ├── requirements.txt ├── static/ └── wsgi.py
import sys import os import os.path sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), 'cms'))) os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'cms.settings') from django.core.wsgi import get_wsgi_application application = get_wsgi_application()