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

14 lines
341 B
Python
Raw Permalink Normal View History

2020-11-22 01:20:14 +08:00
from pathlib import Path
from fastapi.staticfiles import StaticFiles
2022-01-15 21:27:43 +08:00
from nonebot.drivers.fastapi import Driver
2020-11-22 01:20:14 +08:00
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())
2022-01-08 19:36:19 +08:00
app.mount("/website", StaticFiles(directory=static_path, html=True), name="docs")