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
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:
21
main.py
21
main.py
@@ -2026,12 +2026,27 @@ def page_not_found(e):
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
if __name__ == '__main__':
|
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
|
# Check to see if --debug is in the command line arguments
|
||||||
if "--debug" in sys.argv:
|
if "--debug" in sys.argv:
|
||||||
app.run(debug=True)
|
app.run(debug=True, host=host, port=port)
|
||||||
else:
|
else:
|
||||||
app.run()
|
app.run(host=host, port=port)
|
||||||
|
|
||||||
def tests():
|
def tests():
|
||||||
assert blocks_to_time(6) == "1 hrs"
|
assert blocks_to_time(6) == "1 hrs"
|
||||||
|
|||||||
Reference in New Issue
Block a user