-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Example for aiohttp server cleaned up + README.md added
- Loading branch information
Showing
6 changed files
with
75 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
Examples for peewee-async | ||
========================= | ||
|
||
To run the examples install dependencies first: | ||
|
||
```bash | ||
pip install -r examples/requirements.txt | ||
``` | ||
|
||
Also please run database service and provide credentials in environment variables. | ||
Feel free to use development database services with the default credentials, e.g: | ||
|
||
```bash | ||
docker compose up postgres | ||
``` | ||
|
||
## Example for `aiohttp` server | ||
|
||
The example `aiohttp_example.py` is using older interface with `Manager` class. The `Manager` | ||
will be deprecated in v1.0 but we aim to support it until that milestone. | ||
|
||
Define database connection settings if needed, environment variables used: | ||
|
||
- `POSTGRES_DB` | ||
- `POSTGRES_USER` | ||
- `POSTGRES_PASSWORD` | ||
- `POSTGRES_HOST` | ||
- `POSTGRES_PORT` | ||
|
||
Run this command to create example tables in the database: | ||
|
||
```bash | ||
python -m examples.aiohttp_example | ||
``` | ||
|
||
Run this command to start an example application: | ||
|
||
```bash | ||
gunicorn --bind 127.0.0.1:8080 --log-level INFO --access-logfile - \ | ||
--worker-class aiohttp.GunicornWebWorker --reload \ | ||
examples.aiohttp_example:app | ||
``` | ||
|
||
Application should be up and running: | ||
|
||
```bash | ||
curl 'http://127.0.0.1:8080/?p=1' | ||
``` | ||
|
||
the output should be: | ||
|
||
``` | ||
This is a first post | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters