Init
This commit is contained in:
2
backend/.gitignore
vendored
Normal file
2
backend/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
.venv
|
||||
**/__pycache__
|
||||
41
backend/backend/__init__.py
Normal file
41
backend/backend/__init__.py
Normal 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
1
backend/frontend
Symbolic link
@@ -0,0 +1 @@
|
||||
../frontend/build
|
||||
3045
backend/poetry.lock
generated
Normal file
3045
backend/poetry.lock
generated
Normal file
File diff suppressed because one or more lines are too long
17
backend/pyproject.toml
Normal file
17
backend/pyproject.toml
Normal 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"
|
||||
Reference in New Issue
Block a user