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
|
from fastapi import FastAPI, Request
|
||||||
import aiohttp_jinja2
|
from fastapi.templating import Jinja2Templates
|
||||||
|
from starlette.responses import RedirectResponse
|
||||||
|
|
||||||
import jinja2
|
import jinja2
|
||||||
|
|
||||||
|
from pnpdevice.config import config
|
||||||
import pnpdevice.discovery
|
import pnpdevice.discovery
|
||||||
import pnpdevice.relays
|
import pnpdevice.relays
|
||||||
|
|
||||||
def html(text: str) -> web.Response:
|
app = FastAPI(debug=config.DEBUG)
|
||||||
return web.Response(content_type="text/html", text=f"<html>{text}</html>")
|
templates = Jinja2Templates(directory="templates")
|
||||||
|
|
||||||
@aiohttp_jinja2.template("index.template.html")
|
@app.get("/")
|
||||||
async def index(request):
|
def index():
|
||||||
relays = request.app["relays"]
|
relays = request.app["relays"]
|
||||||
return {
|
return templates.TemplateResponse("index.template.html", {
|
||||||
"relays": relays.relays_list(),
|
"relays": relays.relays_list(),
|
||||||
}
|
})
|
||||||
|
|
||||||
@aiohttp_jinja2.template("relay-create.template.html")
|
@app.get("/relay/create")
|
||||||
async def relay_create_get(request: Request):
|
def relay_create_get(request: Request):
|
||||||
"Get the form to create a new relay."
|
"Get the form to create a new relay."
|
||||||
relays = request.app["relays"]
|
relays = request.app["relays"]
|
||||||
pins = relays.pins_list()
|
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):
|
async def relay_create_post(request: Request, chip_and_number: str, name: str):
|
||||||
"Create a new relay."
|
"Create a new relay."
|
||||||
|
|
|
@ -4,9 +4,9 @@ authors = [
|
||||||
{ name = "Eli Ribble", email = "eli@theribbles.org"}
|
{ name = "Eli Ribble", email = "eli@theribbles.org"}
|
||||||
]
|
]
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aiohttp",
|
"fastapi",
|
||||||
"aiohttp_jinja2",
|
|
||||||
"tomli-w",
|
"tomli-w",
|
||||||
|
"uvicorn[standard]",
|
||||||
"zeroconf",
|
"zeroconf",
|
||||||
]
|
]
|
||||||
dynamic = ["version", "description"]
|
dynamic = ["version", "description"]
|
||||||
|
|
Loading…
Reference in New Issue