Skip to content

Experiments with Serverless and Containerized Python Apps

Notifications You must be signed in to change notification settings

Thoughtscript/more_python_api_2024

Repository files navigation

more_python_api

Run the following from the root dir:

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 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

Releases

No releases published

Packages

No packages published

Languages