Your Name 3 tahun lalu
induk
melakukan
bf93a58c8c
1 mengubah file dengan 9 tambahan dan 0 penghapusan
  1. 9 0
      step_question/apis/main.py

+ 9 - 0
step_question/apis/main.py

@@ -7,6 +7,7 @@ from starlette.responses import FileResponse, StreamingResponse
 from fastapi.responses import HTMLResponse
 from fastapi.responses import HTMLResponse
 from fastapi.staticfiles import StaticFiles
 from fastapi.staticfiles import StaticFiles
 import io
 import io
+from starlette.responses import RedirectResponse
 
 
 app = FastAPI()
 app = FastAPI()
 app.add_middleware(
 app.add_middleware(
@@ -45,6 +46,14 @@ async def submit(request: Request):
 
 
 app.mount("/a1", StaticFiles(directory="static"), name="static")
 app.mount("/a1", StaticFiles(directory="static"), name="static")
 
 
+@app.get("/a1")
+async def redirect():
+#    url = app.url_path_for("/a1/index.html")
+    response = RedirectResponse(url='/a1/index.html')
+    return response
+
+#@app.get("/a1", response_class=HTMLResponse)
+
 #@app.get("/a1", response_class=HTMLResponse)
 #@app.get("/a1", response_class=HTMLResponse)
 #async def read_items():
 #async def read_items():
 #    return """
 #    return """