Raymond Weitekamp commited on
Commit
67e0e6d
·
1 Parent(s): 9f9700b

Fix port binding conflicts between Nginx and application

Browse files
Files changed (2) hide show
  1. cadviewer.py +13 -8
  2. start.sh +2 -2
cadviewer.py CHANGED
@@ -219,13 +219,18 @@ def handle_key(e: KeyEventArguments):
219
  keyboard = ui.keyboard(on_key=handle_key)
220
  # TODO: consider separating this module and how best to organize it (if name == main, etc.)
221
  app.on_shutdown(shutdown_all) # register shutdown handler
222
- ui.run(
223
- native=False, # Changed from True to False for web deployment
224
- host='0.0.0.0', # Listen on all interfaces
225
- port=7860, # Use port 7860 for Spaces
226
- title="nicegui-cadviewer",
227
- reload=False
228
- )
229
- # ui.run(native=True, window_size=(1800, 900), fullscreen=False, reload=True) #use reload=True when developing rapidly, False helps exit behavior
 
 
 
 
 
230
 
231
  # layout info https://github.com/zauberzeug/nicegui/discussions/1937
 
219
  keyboard = ui.keyboard(on_key=handle_key)
220
  # TODO: consider separating this module and how best to organize it (if name == main, etc.)
221
  app.on_shutdown(shutdown_all) # register shutdown handler
222
+
223
+ def main():
224
+ startup_all()
225
+ ui.run(
226
+ native=False,
227
+ host='0.0.0.0',
228
+ port=7861, # Use 7861 consistently
229
+ title="nicegui-cadviewer",
230
+ reload=False
231
+ )
232
+
233
+ if __name__ == "__main__":
234
+ main()
235
 
236
  # layout info https://github.com/zauberzeug/nicegui/discussions/1937
start.sh CHANGED
@@ -1,7 +1,7 @@
1
  #!/bin/bash
2
 
3
- # Start Nginx
4
  nginx
5
 
6
  # Start the application on port 7861 (Nginx will proxy from 7860)
7
- python -c "import cadviewer; from nicegui import app; app.native.start_args['port'] = 7861; cadviewer.ui.run(native=False, host='0.0.0.0', port=7861)"
 
1
  #!/bin/bash
2
 
3
+ # Start Nginx (which listens on 7860)
4
  nginx
5
 
6
  # Start the application on port 7861 (Nginx will proxy from 7860)
7
+ python -m cadviewer