diff --git a/favicon_app/routes/favicon_service.py b/favicon_app/routes/favicon_service.py index 5abee88..75cf6e4 100644 --- a/favicon_app/routes/favicon_service.py +++ b/favicon_app/routes/favicon_service.py @@ -125,6 +125,8 @@ async def get_icon_async(entity: Favicon, _cached: bytes = None) -> Optional[byt lambda: ('', "网站默认位置/favicon.ico"), # 4. 从其他api接口获取 lambda: (f'https://ico.kucat.cn/get.php?url={entity.get_base_url()}', "第三方API"), + # 99. 最后的尝试,cloudflare workers + # lambda: (f'https://favicon.cary.cc/?url={entity.get_base_url()}', "cloudflare"), ] for strategy in strategies: @@ -193,8 +195,6 @@ def _parse_html(content: Optional[bytes], entity: Favicon) -> Optional[str]: try: # 尝试将bytes转换为字符串 - # str(content).encode('utf-8', 'replace').decode('utf-8', 'replace') - # content_str = content.decode('utf-8', 'replace') content_str = str(content).encode('utf-8', 'replace').decode('utf-8', 'replace') # 使用更高效的解析器 diff --git a/run.py b/run.py index 5599b04..97333b6 100644 --- a/run.py +++ b/run.py @@ -1,5 +1,7 @@ # -*- coding: utf-8 -*- +import asyncio + import uvicorn @@ -8,21 +10,12 @@ async def main(): "main:app", host="127.0.0.1", port=8000, - # reload=True, + reload=False, log_level="info", ) server = uvicorn.Server(config) await server.serve() - # asyncio.run(main()) if __name__ == "__main__": - config = uvicorn.Config( - "main:app", - host="127.0.0.1", - port=8000, - # reload=True, - log_level="info", - ) - server = uvicorn.Server(config) - server.run() + asyncio.run(main())