python使用FastAPI返回简单html页面
# pip install uvicorn prometheus_client
# pip install fastapi yaml
# uvicorn main:app --reload
from fastapi import FastAPI
from fastapi.responses import PlainTextResponse,HTMLResponse
import uvicorn
app = FastAPI()
@app.get('/', response_class=HTMLResponse)
async def list_url():
return """
<html>
<body>
<h1> 标题1: </h1>
<h2> 标题2: </h2>
<li><a target="_blank" href="http://localhost:8080">展示的地址1:http://localhost:8080 </a>备注</li>
<h2> 标题2: </h2>
<li><a target="_blank" href="http://localhost:8080">展示的地址2:http://localhost:8080 </a>备注</li>
</body>
</html>
"""
# 多个实例的监控返回
if __name__ == "__main__":
uvicorn.run(app='list_jq_url:app', host="0.0.0.0", port=8000,reload=True)