Skip to content

Commit

Permalink
Minimal changes, and moved the environment variables
Browse files Browse the repository at this point in the history
possible fix for dabapps#25 on main repo

dabapps#25
  • Loading branch information
Mistium authored Aug 19, 2024
1 parent 02f809a commit c17b5b1
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions crab/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@ def proxy(path):
stream=True,
)

# We need to remove the transfer-encoding header as this will
# no longer apply to the response we are about to send
"""
We need to remove the transfer-encoding header as this will
no longer apply to the response we are about to send
"""

downstream_response.raw.headers.pop("transfer-encoding", None)

return Response(
Expand All @@ -65,19 +68,25 @@ def start_on_port(port):
use_debugger=False,
use_reloader=False,
load_dotenv=False,
host=os.environ.get("CRAB_ROUTER_HOST"),
host=os.environ.get(router_host),
)


def run():
if "CRAB_ROUTER_PORT" in os.environ:
start_on_port(int(os.environ["CRAB_ROUTER_PORT"]))
if router_port in os.environ:
start_on_port(int(os.environ[router_port]))
else:
try:
start_on_port(80)
start_on_port(default_port)
except:
start_on_port(8080)
start_on_port(fallback_port)


if __name__ == "__main__":
# Environment Variables
router_port = "CRAB_ROUTER_PORT"
router_host = "CRAB_ROUTER_HOST"
default_port = 80
fallback_port = 8080

run()

0 comments on commit c17b5b1

Please sign in to comment.