Skip to content

Latest commit

 

History

History
66 lines (45 loc) · 2.01 KB

README.md

File metadata and controls

66 lines (45 loc) · 2.01 KB

Python Applications

Install Procedure

  1. Create a Python/uWSGI application via the Control Panel (Opalstack doc).
  2. Execute app-template-py APP_NAME [PY_VERSION] (doc).
  3. Copy your application files in the app directory.
  4. Modify uwsgi.ini if/as needed.
  5. Start the application: app-control APP_NAME start.

Controlling Your Application

See app-control.

Directory Structure

  • app: Your application.
    • config
      • wsgi.py: WSGI config for your application (used in /uwsgi.ini, cf. below).
  • venv: Python 3 virtual environment (Python doc)
  • tmp: Temporary files used by your application
    • uwsgi.pid: PID file
  • opalstack-requirements.txt: pip requirements related to the Opalstack app.
  • uwsgi.ini: uWSGI configuration (uWSGI options).

Django

To create a Django application, you can start with the following…
(replace APP_NAME, MY_PROJECT, and your-domain.com with your values)

cd $HOME/apps/APP_NAME/

. venv/bin/activate
pip install django

cd tmp
django-admin startproject MY_PROJECT
mv MY_PROJECT/* ../app/
rmdir MY_PROJECT

cd ..
sed -i "s/ALLOWED_HOSTS = \[\]/ALLOWED_HOSTS = ['your-domain.com']/" app/MY_PROJECT/settings.py
sed -i "/DATABASES =/, /^}/ s/^/# /" app/MY_PROJECT/settings.py
sed -i "s#config/wsgi.\py#MY_PROJECT/wsgi.py#g" uwsgi.ini

app-control APP_NAME restart

# Fine-tuning ;-)
cd venv/bin/
rm django-admin.py
ln -s ../../app/manage.py
cd ../..

And you should see the default "The install worked successfully! Congratulations!" page on http://your-domain.com/

Opalstack Documentation