Abhaykoul commited on
Commit
fc866a0
·
verified ·
1 Parent(s): 1a631f3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -1
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import re
2
  import requests
3
  from fastapi import FastAPI, HTTPException
 
4
  from pydantic import BaseModel
5
  from dotenv import load_dotenv
6
  import os
@@ -12,7 +13,15 @@ load_dotenv()
12
  API_URL = os.getenv("API_URL")
13
  MODEL = os.getenv("MODEL")
14
  Origin = os.getenv("ORIGIN")
15
- app = FastAPI()
 
 
 
 
 
 
 
 
16
 
17
  class RoastRequest(BaseModel):
18
  content: str
@@ -39,6 +48,10 @@ def fetch_roasts(content: str):
39
  except Exception as e:
40
  raise HTTPException(status_code=500, detail=f"Unexpected error: {e}")
41
 
 
 
 
 
42
  @app.post("/generate-roasts/")
43
  async def generate_roasts(request: RoastRequest):
44
  roasts = fetch_roasts(request.content)
 
1
  import re
2
  import requests
3
  from fastapi import FastAPI, HTTPException
4
+ from fastapi.responses import RedirectResponse
5
  from pydantic import BaseModel
6
  from dotenv import load_dotenv
7
  import os
 
13
  API_URL = os.getenv("API_URL")
14
  MODEL = os.getenv("MODEL")
15
  Origin = os.getenv("ORIGIN")
16
+
17
+ # Initialize FastAPI app with custom documentation URLs
18
+ app = FastAPI(
19
+ title="Roast API",
20
+ description="API for generating custom roasts. For more details, visit [Roast API Documentation](https://roastapi-docs.netlify.app/).",
21
+ version="1.0.0",
22
+ docs_url="/docs",
23
+ openapi_url="/openapi.json"
24
+ )
25
 
26
  class RoastRequest(BaseModel):
27
  content: str
 
48
  except Exception as e:
49
  raise HTTPException(status_code=500, detail=f"Unexpected error: {e}")
50
 
51
+ @app.get("/", include_in_schema=False)
52
+ async def root():
53
+ return RedirectResponse(url="https://roastapi-docs.netlify.app/")
54
+
55
  @app.post("/generate-roasts/")
56
  async def generate_roasts(request: RoastRequest):
57
  roasts = fetch_roasts(request.content)