From 4d4ca132e94c20898da9dc5b6813e44180ba1db6 Mon Sep 17 00:00:00 2001 From: Allisson Azevedo Date: Sun, 10 Dec 2023 17:36:31 -0300 Subject: [PATCH] fix: Change templates.env.globals["url_for"] --- Dockerfile | 9 +-------- README.md | 2 +- fly.toml | 29 +++++++++++++++++++++++++++++ poetry.lock | 14 +++++++------- secure_qrcode/api.py | 1 + 5 files changed, 39 insertions(+), 16 deletions(-) create mode 100644 fly.toml diff --git a/Dockerfile b/Dockerfile index af05a75..eacb6ff 100644 --- a/Dockerfile +++ b/Dockerfile @@ -33,13 +33,6 @@ ENV PYTHONPATH /app # Copy content from builder stage COPY --from=builder /app /app -# Install packages -RUN apt-get update && \ - apt-get upgrade -y && \ - apt-get install --no-install-recommends -y tini && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* - # Add qrcode user and create directories RUN useradd -m qrcode && mkdir -p /app @@ -54,4 +47,4 @@ USER qrcode EXPOSE 8000 # Set entrypoint and cmd -ENTRYPOINT ["/usr/bin/tini", "--", "uvicorn", "--host", "0.0.0.0", "--port", "8000", "secure_qrcode.api:app"] +ENTRYPOINT ["uvicorn", "--host", "0.0.0.0", "--port", "8000", "secure_qrcode.api:app"] diff --git a/README.md b/README.md index 86eadb8..6df59e7 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Encrypt your data using the modern ChaCha20-Poly1305 cipher and export it into a ## access via browser -Open the url https://secure-qrcode.onrender.com on your browser. +Open the url https://secure-qrcode.fly.dev on your browser. If you want to run this on your local machine, see the next section. diff --git a/fly.toml b/fly.toml new file mode 100644 index 0000000..7a314de --- /dev/null +++ b/fly.toml @@ -0,0 +1,29 @@ +# fly.toml app configuration file generated for secure-qrcode on 2023-12-10T16:41:32-03:00 +# +# See https://fly.io/docs/reference/configuration/ for information about how to use this file. +# + +app = "secure-qrcode" +primary_region = "dfw" + +[build] + +[http_service] + internal_port = 8000 + force_https = true + auto_stop_machines = true + auto_start_machines = true + min_machines_running = 0 + processes = ["app"] + +[[http_service.checks]] + grace_period = "10s" + interval = "60s" + method = "GET" + timeout = "5s" + path = "/healthz" + +[[vm]] + cpu_kind = "shared" + cpus = 1 + memory_mb = 256 diff --git a/poetry.lock b/poetry.lock index 91562f0..f3cd00f 100644 --- a/poetry.lock +++ b/poetry.lock @@ -539,13 +539,13 @@ testing = ["pytest", "pytest-benchmark"] [[package]] name = "pre-commit" -version = "3.5.0" +version = "3.6.0" description = "A framework for managing and maintaining multi-language pre-commit hooks." optional = false -python-versions = ">=3.8" +python-versions = ">=3.9" files = [ - {file = "pre_commit-3.5.0-py2.py3-none-any.whl", hash = "sha256:841dc9aef25daba9a0238cd27984041fa0467b4199fc4852e27950664919f660"}, - {file = "pre_commit-3.5.0.tar.gz", hash = "sha256:5804465c675b659b0862f07907f96295d490822a450c4c40e747d0b1c6ebcb32"}, + {file = "pre_commit-3.6.0-py2.py3-none-any.whl", hash = "sha256:c255039ef399049a5544b6ce13d135caba8f2c28c3b4033277a788f434308376"}, + {file = "pre_commit-3.6.0.tar.gz", hash = "sha256:d30bad9abf165f7785c15a21a1f46da7d0677cb00ee7ff4c579fd38922efe15d"}, ] [package.dependencies] @@ -939,13 +939,13 @@ full = ["httpx (>=0.22.0)", "itsdangerous", "jinja2", "python-multipart", "pyyam [[package]] name = "typing-extensions" -version = "4.8.0" +version = "4.9.0" description = "Backported and Experimental Type Hints for Python 3.8+" optional = false python-versions = ">=3.8" files = [ - {file = "typing_extensions-4.8.0-py3-none-any.whl", hash = "sha256:8f92fc8806f9a6b641eaa5318da32b44d401efaac0f6678c9bc448ba3605faa0"}, - {file = "typing_extensions-4.8.0.tar.gz", hash = "sha256:df8e4339e9cb77357558cbdbceca33c303714cf861d1eef15e1070055ae8b7ef"}, + {file = "typing_extensions-4.9.0-py3-none-any.whl", hash = "sha256:af72aea155e91adfc61c3ae9e0e342dbc0cba726d6cba4b6c72c1f34e47291cd"}, + {file = "typing_extensions-4.9.0.tar.gz", hash = "sha256:23478f88c37f27d76ac8aee6c905017a143b0b1b886c3c9f66bc2fd94f9f5783"}, ] [[package]] diff --git a/secure_qrcode/api.py b/secure_qrcode/api.py index a622f21..739a59e 100644 --- a/secure_qrcode/api.py +++ b/secure_qrcode/api.py @@ -24,6 +24,7 @@ ) app.mount("/static", StaticFiles(directory="static"), name="static") templates = Jinja2Templates(directory="templates") +templates.env.globals["url_for"] = app.url_path_for @app.exception_handler(DecryptError)