From 665c26cc5d722e9cf62c3dfff37d5c09a89fd3c0 Mon Sep 17 00:00:00 2001
From: "Huu Le (Lee)" <39040748+leehuwuj@users.noreply.github.com>
Date: Fri, 29 Mar 2024 15:04:04 +0700
Subject: [PATCH] feat: Add redirect to document page (#29)

---
 .changeset/forty-ads-tell.md              | 5 +++++
 templates/types/streaming/fastapi/main.py | 7 +++++++
 2 files changed, 12 insertions(+)
 create mode 100644 .changeset/forty-ads-tell.md

diff --git a/.changeset/forty-ads-tell.md b/.changeset/forty-ads-tell.md
new file mode 100644
index 00000000..ef9fed95
--- /dev/null
+++ b/.changeset/forty-ads-tell.md
@@ -0,0 +1,5 @@
+---
+"create-llama": patch
+---
+
+Add redirect to documentation page when accessing the base URL
diff --git a/templates/types/streaming/fastapi/main.py b/templates/types/streaming/fastapi/main.py
index edba3d3a..4ffd54f3 100644
--- a/templates/types/streaming/fastapi/main.py
+++ b/templates/types/streaming/fastapi/main.py
@@ -7,6 +7,7 @@ import os
 import uvicorn
 from fastapi import FastAPI
 from fastapi.middleware.cors import CORSMiddleware
+from fastapi.responses import RedirectResponse
 from app.api.routers.chat import chat_router
 from app.settings import init_settings
 
@@ -29,6 +30,12 @@ if environment == "dev":
         allow_headers=["*"],
     )
 
+    # Redirect to documentation page when accessing base URL
+    @app.get("/")
+    async def redirect_to_docs():
+        return RedirectResponse(url="/docs")
+
+
 app.include_router(chat_router, prefix="/api/chat")
 
 
-- 
GitLab