This commit is contained in:
2022-10-27 15:36:28 +02:00
commit 6ca02566c6
25 changed files with 32027 additions and 0 deletions

2
backend/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
.venv
**/__pycache__

View File

@@ -0,0 +1,41 @@
from fastapi import FastAPI, Request, WebSocket, WebSocketDisconnect
from fastapi.staticfiles import StaticFiles
from fastapi.responses import FileResponse
app = FastAPI()
backend = FastAPI()
@backend.websocket("/client")
async def client_handler(socket: WebSocket):
print("WS opened")
await socket.accept()
while True:
try:
data = await socket.receive_json()
print(f"WS data: {data!r}")
except WebSocketDisconnect:
break
print("WS closed")
frontend = FastAPI()
@frontend.middleware("http")
async def index_catch_all(request: Request, call_next):
response = await call_next(request)
if response.status_code == 404:
return FileResponse("frontend/index.html")
return response
frontend.mount("/", StaticFiles(directory="frontend"))
app.mount("/api/", backend)
app.mount("/", frontend)

1
backend/frontend Symbolic link
View File

@@ -0,0 +1 @@
../frontend/build

3045
backend/poetry.lock generated Normal file

File diff suppressed because one or more lines are too long

17
backend/pyproject.toml Normal file
View File

@@ -0,0 +1,17 @@
[tool.poetry]
name = "backend"
version = "0.1.0"
description = ""
authors = ["Kai Vogelgesang <kai@leafbla.de>"]
readme = "README.md"
[tool.poetry.dependencies]
python = "^3.10"
pyautogui = "^0.9.53"
fastapi = "^0.85.1"
hypercorn = "^0.14.3"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"