FixMiYouShe/main.py

29 lines
789 B
Python
Raw Normal View History

import asyncio
import uvicorn
2023-08-23 09:39:03 +00:00
from src.app import app
2023-08-24 07:35:45 +00:00
from src.env import PORT, MIYOUSHE, HOYOLAB
async def main():
2023-08-24 07:35:45 +00:00
if MIYOUSHE:
from src.render.article import refresh_recommend_posts
await refresh_recommend_posts()
if HOYOLAB:
from src.render.article_hoyolab import refresh_hoyo_recommend_posts
await refresh_hoyo_recommend_posts()
web_server = uvicorn.Server(config=uvicorn.Config(app, host="0.0.0.0", port=PORT))
server_config = web_server.config
server_config.setup_event_loop()
if not server_config.loaded:
server_config.load()
web_server.lifespan = server_config.lifespan_class(server_config)
await web_server.startup()
await web_server.main_loop()
2023-08-23 09:39:03 +00:00
if __name__ == "__main__":
asyncio.run(main())