25.09.10
parent
0adc1e717d
commit
ce4135a809
|
@ -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')
|
||||
|
||||
# 使用更高效的解析器
|
||||
|
|
15
run.py
15
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())
|
||||
|
|
Loading…
Reference in New Issue