nonebot2/packages/nonebot-plugin-docs/nonebot_plugin_docs/drivers/fastapi.py

13 lines
337 B
Python
Raw Normal View History

2020-11-22 01:20:14 +08:00
from pathlib import Path
from nonebot.drivers.fastapi import Driver
from fastapi.staticfiles import StaticFiles
2020-11-22 02:17:13 +08:00
def register_route(driver: Driver):
2020-11-22 01:20:14 +08:00
app = driver.server_app
static_path = str((Path(__file__).parent / ".." / "dist").resolve())
app.mount("/docs", StaticFiles(directory=static_path, html=True), name="docs")