How to serve static files in FastAPI
问题 I am trying to serve static files that I have in a package_docs directory. When I open in the browzer: http://127.0.0.1:8001/packages/docs/index.html , the page is running. But I want to open the page: http://127.0.0.1:8001/packages/docs/ without the source file. And the output is 404 Not Found app.mount("/packages/docs", StaticFiles(directory=pkg_resources.resource_filename(__name__, 'package_docs') ), name="package_docs") @app.get("/packages/docs/.*", include_in_schema=False) def root():