From 39b804da5503a3a4adad929e36cd291fbc92b61b Mon Sep 17 00:00:00 2001 From: ThePhaseless Date: Wed, 1 Oct 2025 12:09:53 +0000 Subject: [PATCH] add host and port as env --- README.md | 5 +++-- main.py | 6 ++---- src/consts.py | 3 +++ 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index b549b16..81aef00 100644 --- a/README.md +++ b/README.md @@ -34,9 +34,10 @@ Built with [camoufox](https://camoufox.com/) and [FastAPI](https://fastapi.tiang ## Options | Environment Variable | Default | Description | -| -------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| -------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | --- | | `HOST` | `0.0.0.0` | Host address to bind the server to. Use `0.0.0.0` to bind to all IPv4 interfaces, `::` for all IPv6 interfaces, or `127.0.0.1`/`localhost` for local access only. | -| `PROXY_SERVER` | None | Proxy to use in format: `protocol://host:port`. | +| `PORT` | `8196` | Port to bind the server to. | +| `PROXY_SERVER` | None | Proxy to use in format: `protocol://host:port`. | w | | `PROXY_USERNAME` | None | | | `PROXY_PASSWORD` | None | | diff --git a/main.py b/main.py index 8fe1424..308479b 100644 --- a/main.py +++ b/main.py @@ -2,14 +2,13 @@ from __future__ import annotations import asyncio import logging -import os import sys import uvicorn from fastapi import FastAPI from fastapi.middleware.gzip import GZipMiddleware -from src.consts import LOG_LEVEL, VERSION +from src.consts import HOST, LOG_LEVEL, PORT, VERSION from src.endpoints import health_check, router from src.middlewares import LogRequest from src.utils import get_camoufox, logger @@ -39,5 +38,4 @@ if __name__ == "__main__": loop.run_until_complete(init()) logger.info("Initialization complete.") else: - host = os.getenv("HOST", "0.0.0.0") # noqa: S104 - uvicorn.run(app, host=host, port=8191) + uvicorn.run(app, host=HOST, port=PORT) diff --git a/src/consts.py b/src/consts.py index 9607a23..ad6fb9e 100644 --- a/src/consts.py +++ b/src/consts.py @@ -19,6 +19,9 @@ PROXY_SERVER = os.getenv("PROXY_SERVER") PROXY_USERNAME = os.getenv("PROXY_USERNAME") PROXY_PASSWORD = os.getenv("PROXY_PASSWORD") +HOST = os.getenv("HOST", "0.0.0.0") +PORT = int(os.getenv("PORT", "8191")) + CHALLENGE_TITLES_MAP: dict[CaptchaType, list[str]] = { # Cloudflare CaptchaType.CLOUDFLARE_INTERSTITIAL: ["Just a moment..."],