This is a Python example app made for the Gleis PaaS built using the Django web framework.
In order to run this sample app locally you will need Python to be installed on your computer and an account on the Gleis PaaS as well as the Gleis CLI Ruby gem to be able to deploy it.
Download your own copy of this sample app:
$ git clone git@github.com:towards/python-example.git
$ cd python-example
Install dependencies:
$ pip install -r requirements.txt
Apply pending database migrations:
$ python manage.py migrate
Collect static files into static directory:
$ python manage.py collectstatic
Start app:
$ python manage.py runserver
The sample app should now be reachable locally at http://localhost:8000/
Create new app on Gleis:
$ gleis app create
Create new PostgreSQL database for app on Gleis:
$ gleis db new
Upload app to Gleis:
$ git push gleis master
Apply pending database migrations:
$ gleis app exec "python manage.py migrate"
The sample app will be online in a few seconds and reachable through the secure URL mentioned when you created the Gleis app with the above command.
In this sample app, Django is configured to use:
- SQLite as default database when run locally
- PostgreSQL as database when deployed on Gleis
- DJ-Database-URL to automatically read the DATABASE_URL config var on Gleis to connect to the PostgreSQL database
- WhiteNoise for serving static files directly from the web server