Upload 4 files
Browse files
app.py
CHANGED
|
@@ -26,10 +26,14 @@ os.environ['GROQ_API_KEY'] = os.getenv("GROQ_API_KEY")
|
|
| 26 |
# Initialize FastAPI
|
| 27 |
app = FastAPI()
|
| 28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
# Add CORS middleware
|
| 30 |
app.add_middleware(
|
| 31 |
CORSMiddleware,
|
| 32 |
-
allow_origins=
|
| 33 |
allow_credentials=True,
|
| 34 |
allow_methods=["*"], # Allows all methods (GET, POST, PUT, DELETE, etc.)
|
| 35 |
allow_headers=["*"], # Allows all headers
|
|
@@ -275,7 +279,3 @@ def home():
|
|
| 275 |
return {"message": "Welcome to the Text Generation API"}
|
| 276 |
|
| 277 |
|
| 278 |
-
# Run the FastAPI app with Uvicorn
|
| 279 |
-
if __name__ == "__main__":
|
| 280 |
-
import uvicorn
|
| 281 |
-
uvicorn.run("app:app", host="0.0.0.0", port=8000, reload=True)
|
|
|
|
| 26 |
# Initialize FastAPI
|
| 27 |
app = FastAPI()
|
| 28 |
|
| 29 |
+
origins = [
|
| 30 |
+
"https://codebug.lk",
|
| 31 |
+
"http://localhost:3000"
|
| 32 |
+
]
|
| 33 |
# Add CORS middleware
|
| 34 |
app.add_middleware(
|
| 35 |
CORSMiddleware,
|
| 36 |
+
allow_origins=origins, # Allows all origins, you can specify a list of allowed origins
|
| 37 |
allow_credentials=True,
|
| 38 |
allow_methods=["*"], # Allows all methods (GET, POST, PUT, DELETE, etc.)
|
| 39 |
allow_headers=["*"], # Allows all headers
|
|
|
|
| 279 |
return {"message": "Welcome to the Text Generation API"}
|
| 280 |
|
| 281 |
|
|
|
|
|
|
|
|
|
|
|
|