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-exampleInstall dependencies:
$ pip install -r requirements.txtApply pending database migrations:
$ python manage.py migrateCollect static files into static directory:
$ python manage.py collectstaticStart app:
$ python manage.py runserverThe sample app should now be reachable locally at http://localhost:8000/
Create new app on Gleis:
$ gleis app createCreate new PostgreSQL database for app on Gleis:
$ gleis db newUpload app to Gleis:
$ git push gleis masterApply 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