Skip to content

Simple project based on FastAPI that imports a directory of functions (single python files) and exposes them on port 80

License

Notifications You must be signed in to change notification settings

brendanc-dpaw/lazyapi

 
 

Repository files navigation

lazyapi

Build Status

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 app
  • lazyapi.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

About

Simple project based on FastAPI that imports a directory of functions (single python files) and exposes them on port 80

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 98.2%
  • Dockerfile 1.8%