Merge pull request #3 from brosner/05-24-add_port_env_override

add PORT env override
This commit is contained in:
Brian Rosner 2024-05-24 22:41:42 -06:00 committed by GitHub
commit f56de15674
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 2 deletions

View File

@ -24,7 +24,7 @@ def test_cli_server_dev(MockApplication):
MockApplication.assert_called_once_with( MockApplication.assert_called_once_with(
{ {
"bind": "127.0.0.1:8000", "bind": "0.0.0.0:8000",
"reload": True, "reload": True,
} }
) )

View File

@ -1,3 +1,4 @@
import os
import sys import sys
import click import click
@ -14,8 +15,9 @@ def cli():
@cli.command() @cli.command()
@click.option("--dev/--no-dev", default=False) @click.option("--dev/--no-dev", default=False)
def server(dev): def server(dev):
port = os.environ.get("PORT", 8000)
cfg = { cfg = {
"bind": "127.0.0.1:8000", "bind": f"0.0.0.0:{port}",
"reload": dev, "reload": dev,
} }
teufa.server.Application(cfg).run() teufa.server.Application(cfg).run()