Simple project based on FastAPI that imports a directory of functions (single python files) and exposes them on port 80
Structure:
main.py
- uvicorn entrypoint that imports functions dir and exposes applazyapi.py
- creates fastapi app and loads dotenv (for local dev)functions/__init__.py
- indexes all functions for import *functions/mycoolfunc.py
- any set of functions/routes
Within a function can just import app and register urls as per FastAPI Docs
#!/usr/bin/env python
from lazyapi import app
import os
@app.get("/some/neat/url")
def some_func_name():
APIKEY = os.getenv("SOME_API_KEY")
Then you can build it and fire your webhooks!
vim .env # fill with secrets
docker build . -t lazyapi
docker run -d --env .env --name lazyapi -p 8000:80 lazyapi
curl localhost:8000/some/neat/url