From c04b2a41024cea7d4866d3e77bf3eebb8f408220 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Sat, 29 Jul 2023 21:58:59 -0700 Subject: [PATCH] Fix an issue with hypercorn not finding the application in the docker image; correct the README; fix a co-routine that wasn't being awaited --- Dockerfile.nightly | 2 +- Dockerfile.release | 2 +- README.rst | 2 +- codesmidgen/views.py | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Dockerfile.nightly b/Dockerfile.nightly index 416b32a..3230dae 100644 --- a/Dockerfile.nightly +++ b/Dockerfile.nightly @@ -6,4 +6,4 @@ RUN pip install -e . RUN pip install hypercorn EXPOSE 8000 -CMD ["hypercorn", "codesmidgen.app"] +CMD ["hypercorn", "codesmidgen.app:application"] diff --git a/Dockerfile.release b/Dockerfile.release index ceaf5fe..3b69e3b 100644 --- a/Dockerfile.release +++ b/Dockerfile.release @@ -3,4 +3,4 @@ FROM python:3.11 RUN pip install --extra-index-url https://git.snyman.info/api/packages/raoul/pypi/simple/ CodeSmidgen hypercorn EXPOSE 8000 -CMD ["hypercorn", "codesmidgen.app"] +CMD ["hypercorn", "codesmidgen.app:application"] diff --git a/README.rst b/README.rst index 5efe224..f345fef 100644 --- a/README.rst +++ b/README.rst @@ -26,7 +26,7 @@ The easiest way to install CodeSmidgen is via Docker and Docker Compose. Here's image: git.snyman.info/raoul/codesmidgen:latest env: - SMIDGEN_SECRET_KEY=yoursecrethere - - SQLALCHEMY_DATABASE_URL=postgres://codesmidgen:codesmidgen@postgres/codesmidgen + - SQLALCHEMY_DATABASE_URI=postgresql://codesmidgen:codesmidgen@postgres/codesmidgen restart: unless-stopped ports: - "127.0.0.1:8000:8000" diff --git a/codesmidgen/views.py b/codesmidgen/views.py index 1921f07..1f71fda 100644 --- a/codesmidgen/views.py +++ b/codesmidgen/views.py @@ -101,7 +101,7 @@ async def save() -> Response: session.commit() return redirect('/' + note.url) except Exception as e: - flash(str(e), 'danger') + await flash(str(e), 'danger') session.rollback() return redirect('/') @@ -115,7 +115,7 @@ async def view(note_url: str) -> Response | str: """ note = Smidgen.query.filter(Smidgen.url == note_url).first() if not note: - flash('That note does not exist', 'danger') + await flash('That note does not exist', 'danger') return redirect('/') lexer = get_lexer_by_name(note.lexer) @@ -133,7 +133,7 @@ async def raw(note_url: str) -> Response | str: """ note = Smidgen.query.filter(Smidgen.url == note_url).scalar() if not note: - flash('That note does not exist', 'danger') + await flash('That note does not exist', 'danger') return redirect('/') return await render_template('raw.html', source=note.source), 200, {'Content-Type': 'text/plain; charset=utf-8'}