https://github.com/thoughtscript/more_python_api_2024
Experiments with Serverless and Containerized Python Apps
https://github.com/thoughtscript/more_python_api_2024
aws docker docker-compose fastapi postgres postgres-jsonb python serverless
Last synced: 25 days ago
JSON representation
Experiments with Serverless and Containerized Python Apps
- Host: GitHub
- URL: https://github.com/thoughtscript/more_python_api_2024
- Owner: Thoughtscript
- Created: 2024-05-01T20:58:21.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-29T22:32:54.000Z (about 1 year ago)
- Last Synced: 2025-03-18T08:14:31.986Z (10 months ago)
- Topics: aws, docker, docker-compose, fastapi, postgres, postgres-jsonb, python, serverless
- Language: Python
- Homepage:
- Size: 11.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# more_python_api
[](https://www.python.org/downloads/) [](https://www.docker.com/) [](https://hub.docker.com/_/postgres/) [](https://www.serverless.com/plugins/serverless-offline)
Run the following from the root dir:
```bash
docker-compose up
# If using Docker Compose Engine V2:
docker compose up
```
## Serverless
Expands on some great examples from: https://github.com/dstilesr/sls-docker-python/blob/master/Dockerfile and https://github.com/aztecweb/docker-serverless-offline.
1. Updates the config.
2. Adds Python dependencies.
3. Some `sls` CLI flags have changed.
4. Adds a Database connection to the example.
* `http://localhost:3001/dev/psqljson` - returns JSON interpolation
* `http://localhost:3001/dev/examples` - returns Examples list from within a Python Serverless function.
* `http://localhost:3001/dev/otherapi` - calls another API deployment (common in layered microservice apps) and returns the retreived value.
## Fast API
* `http://localhost:8001/examples`
* `http://localhost:8001/` - test/heartbeat endpoint for debugging Docker.
## Postgres
1. The DB will execute scripts in [init_json_sql.sql](postgres/init_json_sql.sql) on initialization.
2. These primarily showcase how to use postgres JSON functionalities ("NoSQL in SQL") and non-rectangular **Record Sets**.
## Resources and Links
1. https://realpython.com/fastapi-python-web-apis/
2. https://github.com/dstilesr/sls-docker-python/blob/master/Dockerfile
3. https://github.com/aztecweb/docker-serverless-offline
4. https://www.serverless.com/plugins/serverless-offline
5. https://stackoverflow.com/questions/40741282/cannot-use-requests-module-on-aws-lambda