title: How to serve static files in FastAPI
body: <p>I am trying to serve static files that I have in a package_docs directory. When I open in the browzer: </p>
  
  <p><a href="http://127.0.0.1:8001/packages/docs/index.html" rel="noreferrer">http://127.0.0.1:8001/packages/docs/index.html</a> , the page is running.</p>
  
  <p>But I want to open the page: <a href="http://127.0.0.1:8001/packages/docs/" rel="noreferrer">http://127.0.0.1:8001/packages/docs/</a> </p>
  
  <p>without the source file. And the output is  <code>404 Not Found</code>   </p>
  
  <pre><code>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():
      return HTMLResponse(pkg_resources.resource_string(__name__, "package_docs/index.html"))
  
  
  app.include_router(static.router)
  app.include_router(jamcam.router, prefix="/api/v1/cams", tags=["jamcam"])
  </code></pre>
  
  <p>How can I change my code? Any advice will be helpful. Thank you in advance.</p>