HussainM899
commited on
Update main.py
Browse files
main.py
CHANGED
@@ -7,6 +7,7 @@ from typing import Optional
|
|
7 |
from transformers import pipeline
|
8 |
from pyngrok import ngrok
|
9 |
import nest_asyncio
|
|
|
10 |
|
11 |
# Download NLTK resources
|
12 |
nltk.download('punkt')
|
@@ -41,7 +42,8 @@ class TextInput(BaseModel):
|
|
41 |
# Welcome endpoint
|
42 |
@app.get('/')
|
43 |
async def welcome():
|
44 |
-
|
|
|
45 |
|
46 |
# Sentiment analysis endpoint
|
47 |
@app.post('/analyze/')
|
@@ -63,7 +65,7 @@ async def Predict_Sentiment(text_input: TextInput):
|
|
63 |
# Run the FastAPI app using Uvicorn
|
64 |
if __name__ == "__main__":
|
65 |
# Create ngrok tunnel
|
66 |
-
ngrok_tunnel = ngrok.connect(
|
67 |
print('Public URL:', ngrok_tunnel.public_url)
|
68 |
|
69 |
# Allow nested asyncio calls
|
@@ -71,4 +73,4 @@ if __name__ == "__main__":
|
|
71 |
|
72 |
# Run the FastAPI app with Uvicorn
|
73 |
import uvicorn
|
74 |
-
uvicorn.run(app, port=
|
|
|
7 |
from transformers import pipeline
|
8 |
from pyngrok import ngrok
|
9 |
import nest_asyncio
|
10 |
+
from fastapi.responses import RedirectResponse
|
11 |
|
12 |
# Download NLTK resources
|
13 |
nltk.download('punkt')
|
|
|
42 |
# Welcome endpoint
|
43 |
@app.get('/')
|
44 |
async def welcome():
|
45 |
+
# Redirect to the Swagger UI page
|
46 |
+
return RedirectResponse(url="/docs")
|
47 |
|
48 |
# Sentiment analysis endpoint
|
49 |
@app.post('/analyze/')
|
|
|
65 |
# Run the FastAPI app using Uvicorn
|
66 |
if __name__ == "__main__":
|
67 |
# Create ngrok tunnel
|
68 |
+
ngrok_tunnel = ngrok.connect(7860)
|
69 |
print('Public URL:', ngrok_tunnel.public_url)
|
70 |
|
71 |
# Allow nested asyncio calls
|
|
|
73 |
|
74 |
# Run the FastAPI app with Uvicorn
|
75 |
import uvicorn
|
76 |
+
uvicorn.run(app, port=7860)
|