Checkpoint, switching computers.
This commit is contained in:
parent
c36a32179a
commit
57d8ff0b39
|
@ -0,0 +1,8 @@
|
|||
from starlette.config import Config
|
||||
|
||||
config = Config(".env")
|
||||
|
||||
DEBUG = config("DEBUG", cast=bool, default=False)
|
||||
DATABASE = config("DATABASE_URL", cast=databases.DatabaseURL)
|
||||
SECRET_KEY = config("SECRET_KEY", cast=Secret)
|
||||
ALLOWED_HOSTS = config("ALLOWED_HOSTS", cast=CommaSeparatedStrings)
|
|
@ -1,26 +1,29 @@
|
|||
from aiohttp import web
|
||||
import aiohttp_jinja2
|
||||
from fastapi import FastAPI, Request
|
||||
from fastapi.templating import Jinja2Templates
|
||||
from starlette.responses import RedirectResponse
|
||||
|
||||
import jinja2
|
||||
|
||||
from pnpdevice.config import config
|
||||
import pnpdevice.discovery
|
||||
import pnpdevice.relays
|
||||
|
||||
def html(text: str) -> web.Response:
|
||||
return web.Response(content_type="text/html", text=f"<html>{text}</html>")
|
||||
app = FastAPI(debug=config.DEBUG)
|
||||
templates = Jinja2Templates(directory="templates")
|
||||
|
||||
@aiohttp_jinja2.template("index.template.html")
|
||||
async def index(request):
|
||||
@app.get("/")
|
||||
def index():
|
||||
relays = request.app["relays"]
|
||||
return {
|
||||
return templates.TemplateResponse("index.template.html", {
|
||||
"relays": relays.relays_list(),
|
||||
}
|
||||
})
|
||||
|
||||
@aiohttp_jinja2.template("relay-create.template.html")
|
||||
async def relay_create_get(request: Request):
|
||||
@app.get("/relay/create")
|
||||
def relay_create_get(request: Request):
|
||||
"Get the form to create a new relay."
|
||||
relays = request.app["relays"]
|
||||
pins = relays.pins_list()
|
||||
return {"pins": pins}
|
||||
return templates.TemplateResponse("relay-create.template.html", {"pins": pins})
|
||||
|
||||
async def relay_create_post(request: Request, chip_and_number: str, name: str):
|
||||
"Create a new relay."
|
||||
|
|
|
@ -4,9 +4,9 @@ authors = [
|
|||
{ name = "Eli Ribble", email = "eli@theribbles.org"}
|
||||
]
|
||||
dependencies = [
|
||||
"aiohttp",
|
||||
"aiohttp_jinja2",
|
||||
"fastapi",
|
||||
"tomli-w",
|
||||
"uvicorn[standard]",
|
||||
"zeroconf",
|
||||
]
|
||||
dynamic = ["version", "description"]
|
||||
|
|
Loading…
Reference in New Issue