Johnny0619 commited on
Commit
9c78ee0
·
verified ·
1 Parent(s): 8fc1930

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -2
app.py CHANGED
@@ -3,6 +3,7 @@ import uvicorn
3
  from fastapi import FastAPI, Depends, HTTPException, status
4
  from fastapi.security import HTTPBasic, HTTPBasicCredentials
5
  from fastapi.responses import FileResponse
 
6
 
7
  app = FastAPI()
8
  security = HTTPBasic()
@@ -21,10 +22,32 @@ def authenticate(credentials: HTTPBasicCredentials = Depends(security)):
21
  )
22
  return credentials.username
23
 
 
24
  @app.get("/")
25
  async def read_index(username: str = Depends(authenticate)):
26
- # 認証に成功したらHTMLファイルを返す
27
- return FileResponse('index.html')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
  if __name__ == "__main__":
30
  uvicorn.run(app, host="0.0.0.0", port=7860)
 
3
  from fastapi import FastAPI, Depends, HTTPException, status
4
  from fastapi.security import HTTPBasic, HTTPBasicCredentials
5
  from fastapi.responses import FileResponse
6
+ import os
7
 
8
  app = FastAPI()
9
  security = HTTPBasic()
 
22
  )
23
  return credentials.username
24
 
25
+ # ルート (/) - index.html を表示
26
  @app.get("/")
27
  async def read_index(username: str = Depends(authenticate)):
28
+ # ファイルが存在するか確認(念のため)
29
+ if os.path.exists('index.html'):
30
+ return FileResponse('index.html')
31
+ else:
32
+ return "index.htmlが見つかりません。ファイルをアップロードしてください。"
33
+
34
+ # 業務ポータル (/bussiness_portal) - bussiness_portal.html を表示
35
+ @app.get("/bussiness_portal")
36
+ async def read_bussiness_portal(username: str = Depends(authenticate)):
37
+ file_path = 'bussiness_portal.html'
38
+ if os.path.exists(file_path):
39
+ return FileResponse(file_path)
40
+ else:
41
+ return f"{file_path}が見つかりません。"
42
+
43
+ # 各種登録・福利厚生ガイド (/entry_info) - entry_info.html を表示
44
+ @app.get("/entry_info")
45
+ async def read_entry_info(username: str = Depends(authenticate)):
46
+ file_path = 'entry_info.html'
47
+ if os.path.exists(file_path):
48
+ return FileResponse(file_path)
49
+ else:
50
+ return f"{file_path}が見つかりません。"
51
 
52
  if __name__ == "__main__":
53
  uvicorn.run(app, host="0.0.0.0", port=7860)