fixed port input validation

This commit is contained in:
2026-06-01 13:48:36 +02:00
parent 6ca35c12e2
commit 29df7b2a53

View File

@@ -48,14 +48,15 @@ def creator_page():
).value ).value
# Port # Port
load_dotenv() load_dotenv()
port_min = os.getenv("PORT_MIN") port_min = int(os.getenv("PORT_MIN", 1024))
port_max = os.getenv("PORT_MAX") port_max = int(os.getenv("PORT_MAX", 65535))
port = ui.input( port = ui.input(
label="Port", label="Port",
validation={ validation={
f"Port must be between {str(port_min)} and {str(port_max)}": lambda value: port_min f"Port must be between {str(port_min)} and {str(port_max)}": lambda value: value.isdigit()
<= value and port_min <= int(value) <= port_max,
<= port_max "Port in use": lambda value: value.isdigit()
and not servermanager.is_port_in_use(int(value)),
}, },
) )
# Era # Era