Example Web API application using Python Sanic
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
poetry config virtualenvs.in-project true
$ poetry update
Set environment variables for integrating your database
PG_HOST
: Postgres hostnamePG_PORT
: Postgres portPG_DATABASE
: Posrgres database namePG_USER
: Postgres usernamePG_PASSWORD
: Postgres password
# Example
$ export PG_HOST='localhost'
$ export PG_PORT='5432'
$ export PG_DATABASE='sanic_example'
$ export PG_USER='sanic_example'
$ export PG_PASSWORD='sanic_example'
Create product
table using alembic
You can find initial version of migration file at
alembic/versions/0000_init_products.py
$ alembic upgrade head
You can run application with simple command below
$ source .venv/bin/activate
$ python main.py
Or you can run application with docker
$ docker build -t python-sanic-example:test .
$ docker run -it -p 8080:8080 python-sanic-example:test