__init__.py 881 B

12345678910111213141516171819202122232425262728293031
  1. from .server.app import app
  2. from .server.website import Website
  3. from .server.backend import Backend_Api
  4. def run_gui(host: str = '0.0.0.0', port: int = 80, debug: bool = False) -> None:
  5. config = {
  6. 'host' : host,
  7. 'port' : port,
  8. 'debug': debug
  9. }
  10. site = Website(app)
  11. for route in site.routes:
  12. app.add_url_rule(
  13. route,
  14. view_func = site.routes[route]['function'],
  15. methods = site.routes[route]['methods'],
  16. )
  17. backend_api = Backend_Api(app)
  18. for route in backend_api.routes:
  19. app.add_url_rule(
  20. route,
  21. view_func = backend_api.routes[route]['function'],
  22. methods = backend_api.routes[route]['methods'],
  23. )
  24. print(f"Running on port {config['port']}")
  25. app.run(**config)
  26. print(f"Closing port {config['port']}")