server.py 481 B

123456789101112131415161718192021
  1. import threading
  2. from time import sleep
  3. from nicegui import globals as nicegui_globals
  4. from nicegui import ui
  5. class Server():
  6. def start(self):
  7. self.thread = threading.Thread(target=ui.run, kwargs={'port': 3392, 'show': False, 'reload': False})
  8. self.thread.start()
  9. sleep(1)
  10. def stop(self):
  11. nicegui_globals.server.should_exit = True
  12. self.thread.join()
  13. @property
  14. def base_url(self):
  15. return 'http://localhost:3392'