https://github.com/accent-starlette/boilerplate
Empty boilerplate project for Starlette with docker, auth, css and more.
https://github.com/accent-starlette/boilerplate
boilerplate docker python3 starlette
Last synced: 5 months ago
JSON representation
Empty boilerplate project for Starlette with docker, auth, css and more.
- Host: GitHub
- URL: https://github.com/accent-starlette/boilerplate
- Owner: accent-starlette
- Archived: true
- Created: 2019-05-07T12:13:37.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2022-01-04T17:30:53.000Z (over 3 years ago)
- Last Synced: 2024-08-03T16:15:42.072Z (9 months ago)
- Topics: boilerplate, docker, python3, starlette
- Language: Python
- Homepage:
- Size: 162 KB
- Stars: 6
- Watchers: 4
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Starlette Boilerplate Project
[](https://sourcery.ai)

## Getting Started
Build the container:
```bash
docker-compose build
```Up the container:
```bash
docker-compose up
```Setup your database by creating your first revision, you may need to add some missing imports:
```bash
docker-compose exec app sh
alembic revision --autogenerate -m "first revision"
```Then apply it:
```bash
docker-compose exec app sh
alembic upgrade head
```## Ready!!
The container is ready at http://localhost
## Environment Variables
### base
- ALLOWED_HOSTS
- DATABASE_URL
- DEBUG
- SECRET_KEY
- EMAIL_HOST
- EMAIL_PORT
- EMAIL_DEFAULT_FROM_ADDRESS
- EMAIL_DEFAULT_FROM_NAME
- EMAIL_USERNAME
- EMAIL_PASSWORD### aws
- AWS_ACCESS_KEY_ID
- AWS_SECRET_ACCESS_KEY
- AWS_BUCKET
- AWS_REGION### other
- SENTRY_DSN## Formatting and Linting
Sorts imports, removes unused variables, max line length etc
```bash
docker-compose exec app ./scripts/lint
```## Testing
Run tests and coverage
```bash
docker-compose exec app ./scripts/test
```## New User & Example Scope
```bash
docker-compose exec app python
```The following will just paste into the python shell to
save you copying each line.```python
from app.db import db
from starlette_auth.tables import Scope, User
scope = Scope(code="admin", description="Full administrators access")
user = User(email='[email protected]', first_name='Admin', last_name='User')
user.set_password('password')
user.scopes.append(scope)
user.save()
```## Styles
npm install:
```bash
npm install
```build css:
```bash
npm run watch-css
```## Postgres Query Stats
The following line must be added the the `postgresql.conf` file:
```bash
shared_preload_libraries = 'pg_stat_statements'
```Enable the extension in postgres:
```sql
CREATE EXTENSION pg_stat_statements;
```Reset stats:
```sql
SELECT pg_stat_statements_reset();
```View all logged stats:
```sql
SELECT
query,
calls,
total_time,
min_time,
max_time,
mean_time,
rows,
100.0 * shared_blks_hit / nullif(shared_blks_hit + shared_blks_read, 0) AS hit_percent
FROM pg_stat_statements
INNER JOIN pg_catalog.pg_database db
ON pg_stat_statements.dbid = db.oid
WHERE db.datname = 'appdb'
ORDER BY total_time
DESC LIMIT 25;
```More info: https://www.postgresql.org/docs/current/pgstatstatements.html