This commit is contained in:
Mikaël Capelle
2024-12-18 18:10:57 +00:00
parent eb64edb22f
commit bbb6ca629c
9 changed files with 186 additions and 124 deletions

View File

@@ -1,6 +1,6 @@
FROM python:3.12-alpine
FROM python:3.12-slim
RUN apk add git
RUN apt update && apt install --no-install-recommends -y git gifsicle libgl1
WORKDIR /code
RUN git clone https://gitea.typename.fr/mikael.capelle/advent-of-code .
RUN pip install -e .

View File

@@ -67,13 +67,21 @@ async def file(name: str):
@app.post("/submit-sse")
async def submit_sse(year: int = Form(), day: int = Form(), input: str = Form()):
async def submit_sse(
year: int = Form(), day: int = Form(), input: str = Form(), verbose: bool = Form()
):
data = input.rstrip().replace("\r\n", "\n")
process = await asyncio.create_subprocess_exec(
args = [
"holt59-aoc",
"--stdin",
"--api",
]
if verbose:
args.append("--verbose")
process = await asyncio.create_subprocess_exec(
*args,
"--output",
AOC_FILES_PATH,
"--year",
@@ -97,6 +105,10 @@ async def submit_sse(year: int = Form(), day: int = Form(), input: str = Form())
output = await fp.readline()
if output == b"":
break
if stream == "stderr" and output.startswith(b"OpenCV: FFMPEG"):
continue
await message_queue.put(
{
"type": "stream",