app.py 853 B

12345678910111213141516171819202122232425262728293031
  1. #!/usr/bin/env python
  2. # -*- encoding: utf-8 -*-
  3. """
  4. @Contact : liuyuqi.gov@msn.cn
  5. @Time : 2024/07/26
  6. @License : Copyright © 2017-2022 liuyuqi. All Rights Reserved.
  7. @Desc : enter point
  8. """
  9. from apps import create_app
  10. app = create_app()
  11. if __name__=='__main__':
  12. from dotenv import load_dotenv
  13. import os
  14. if os.path.exists('.env'):
  15. load_dotenv('.env')
  16. _host = os.getenv("HOST") if os.getenv("HOST") is not None else "0.0.0.0"
  17. _port =os.getenv("PORT") if os.getenv("PORT") is not None else "8080"
  18. _debug=os.getenv("DEBUG") if os.getenv("DEBUG") is not None else True
  19. if _debug:
  20. app.run(host=_host, port=_port, debug=_debug)
  21. else :
  22. import uvicorn
  23. from asgiref.wsgi import WsgiToAsgi
  24. asgi_app = WsgiToAsgi(app)
  25. uvicorn.run(asgi_app, host=_host, port=_port,)