feat: Add option to set host and port on main.py entry
All checks were successful
Build Docker / Build Images (map[dockerfile:Dockerfile.hsd tag_suffix:-hsd target:hsd]) (push) Successful in 2m52s
Build Docker / Build Images (map[dockerfile:Dockerfile tag_suffix: target:default]) (push) Successful in 2m56s
Tests and Linting / Tests-Linting (3.11) (push) Successful in 3m3s
Tests and Linting / Tests-Linting (3.10) (push) Successful in 3m5s
Tests and Linting / Tests-Linting (3.13) (push) Successful in 3m6s

This commit is contained in:
2025-09-10 16:18:46 +10:00
parent 938fff8791
commit 0c17c4ad9b

21
main.py
View File

@@ -2026,12 +2026,27 @@ def page_not_found(e):
#endregion
if __name__ == '__main__':
#TODO add parsing to allow for custom port and host
host = '127.0.0.1'
port = 5000
# Check if --host is in the command line arguments
if "--host" in sys.argv:
host_index = sys.argv.index("--host") + 1
if host_index < len(sys.argv):
host = sys.argv[host_index]
# Check if --port is in the command line arguments
if "--port" in sys.argv:
port_index = sys.argv.index("--port") + 1
if port_index < len(sys.argv):
try:
port = int(sys.argv[port_index])
except ValueError:
pass
# Check to see if --debug is in the command line arguments
if "--debug" in sys.argv:
app.run(debug=True)
app.run(debug=True, host=host, port=port)
else:
app.run()
app.run(host=host, port=port)
def tests():
assert blocks_to_time(6) == "1 hrs"