Add new index page
All checks were successful
release-nightly / release-image (push) Has been cancelled
release-tag / release-image (push) Successful in 20m28s

This commit was merged in pull request #6.
This commit is contained in:
2023-09-05 00:07:21 +02:00
parent 20535317c7
commit b82724664e
5 changed files with 198 additions and 170 deletions

View File

@@ -1,9 +1,8 @@
from fastapi import FastAPI, Path, HTTPException, status
from fastapi.responses import RedirectResponse
from fastapi.responses import RedirectResponse, FileResponse
from projectorpi.cli import ProjectorSerial, ExtronSerial
from pydantic import BaseModel
from time import sleep
from http import HTTPStatus
from typing import Optional
import sentry_sdk
@@ -17,6 +16,7 @@ sentry_sdk.init(
app = FastAPI()
extron = ExtronSerial()
projector = ProjectorSerial()
@@ -28,7 +28,8 @@ class Response(BaseModel):
@app.get("/")
async def index() -> RedirectResponse:
return RedirectResponse("/docs", HTTPStatus.MOVED_PERMANENTLY)
return FileResponse("projectorpi_web/index.html")
# return RedirectResponse("/docs", HTTPStatus.MOVED_PERMANENTLY)
@app.post("/sleep", response_model=Response)

View File

@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html>
<head></head>
<body>
<main>
<button class="remote-button" data-direction="up">UP</button>
<button class="remote-button" data-direction="right">RIGHT</button>
<button class="remote-button" data-direction="down">DOWN</button>
<button class="remote-button" data-direction="left">LEFT</button>
<button class="remote-button" data-direction="enter">ENTER</button>
<button class="remote-button" data-direction="menu">MENU</button>
<button class="remote-button" data-direction="vol_up">VOL UP</button>
<button class="remote-button" data-direction="vol_down">VOL DOWN</button>
</main>
<script>
document.addEventListener('DOMContentLoaded', () => {
document.addEventListener('click', (e) => {
let direction = e.target.dataset.direction
fetch(`/control/${direction}`, {method: 'POST'})
});
})
</script>
</body>
</html>