hudolejev / agama

3 stars 3 forks source link

AGAMA: A (very) Generic App to Manage Anything

Simple (and mostly pointless) list management app in Python, Flask and SQLAlchemy.

Screenshot

Purpose

This app is written mainly for demo purposes. It is used to illustrate various aspects of app deployment (not development) and system administration.

Do not treat this code as an example how to write Flask apps -- you can surely find some better ones.

Requirements

Optional for closer-to-production setups:

Installation

Install dependencies; recommended way is to use OS package manager, example for Debian/Ubuntu:

apt install python3-flask-sqlalchemy

Alternative way is to use pip -- but deploying to Python Virtualenv is strongly recommended in this case:

/path/to/pip install Flask-SQLAlchemy

Note: do not use both pip and apt! Choose one method only.

Download the agama.py to the desired location.

That's it -- you're ready to go.

Configuration

AGAMA is configured with environment variables. Currently the only supported parameter is AGAMA_DATABASE_URI which uses the same format as SQLAlchemy database URLs, example for SQLite:

AGAMA_DATABASE_URI=sqlite:////path/to/db.sqlite3

Running

Running manually -- only for development and/or testing purposes, example with SQLite:

export AGAMA_DATABASE_URI=sqlite:////path/to/db.sqlite3
/path/to/python3 /path/to/agama.py

Running with uWSGI -- example with MySQL; database, database user and local system user agama should be created first:

[uwsgi]
chdir = /path/to/agama/dir
module = agama:app
env = AGAMA_DATABASE_URI=mysql://<username>:<password>@<db-host>/<db-name>
plugins = python3
socket = localhost:5000
uid = agama

You can also run it manually with MySQL backend, or with uWSGI and SQLite backend if you want.

Example Nginx configuration for uWSGI setup:

server {
    listen 80 default_server;
    server_name _;

    location / {
        uwsgi_pass localhost:5000;
        include uwsgi_params;
    }
}

Contributing

Issue reports and pull requests are warmly welcome.

Author

Juri Hudolejev -- initial design and implementation.

Special thanks to

License

MIT