Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config: make web application port and hostname configurable #64

Merged
merged 1 commit into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/sambal/__main__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from waitress import serve

from . import app
from . import app, SETTINGS

serve(app, host="127.0.0.1", port=8000)
serve(app, host=SETTINGS["sambal.host"], port=SETTINGS["sambal.port"])
4 changes: 4 additions & 0 deletions src/sambal/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from redis.connection import parse_url

# Read environment variables then do some sanity checks.
HOST = os.getenv("SAMBAL_HOST", default="127.0.0.1")
PORT = int(os.getenv("SAMBAL_PORT", default=8000))
DEBUG = asbool(os.getenv("SAMBAL_DEBUG", default=False))
USE_HTTPS = asbool(os.getenv("SAMBAL_HTTPS", default=False))
USE_HSTS = asbool(os.getenv("SAMBAL_HSTS", default=False))
Expand Down Expand Up @@ -32,6 +34,8 @@
# Pyramid settings are traditionally loaded via PasteDeploy ini file.
# With this project we went a different way with env vars.
SETTINGS = {
"sambal.host": HOST,
"sambal.port": PORT,
"sambal.debug": DEBUG,
"sambal.https": USE_HTTPS,
"sambal.hsts": USE_HSTS,
Expand Down
Loading