Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -63,6 +63,19 @@ def generate_topics(user_input,num_topics):
|
|
| 63 |
subtopics = json_from_text(response_topics)
|
| 64 |
return subtopics
|
| 65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
@app.post("/generate_topics/")
|
| 67 |
async def create_topics(input: TopicInput):
|
| 68 |
topics = generate_topics(input.user_input, input.num_topics)
|
|
|
|
| 63 |
subtopics = json_from_text(response_topics)
|
| 64 |
return subtopics
|
| 65 |
|
| 66 |
+
app.add_middleware(
|
| 67 |
+
CORSMiddleware,
|
| 68 |
+
allow_origins=["*"],
|
| 69 |
+
allow_credentials=True,
|
| 70 |
+
allow_methods=["*"],
|
| 71 |
+
allow_headers=["*"],
|
| 72 |
+
)
|
| 73 |
+
|
| 74 |
+
@app.get("/",tags=["Home"])
|
| 75 |
+
def api_home():
|
| 76 |
+
return {'detail': 'Welcome to FastAPI Subtopics API! /n visit https://pvanand-generate-subtopics.hf.space/docs to test'}
|
| 77 |
+
|
| 78 |
+
|
| 79 |
@app.post("/generate_topics/")
|
| 80 |
async def create_topics(input: TopicInput):
|
| 81 |
topics = generate_topics(input.user_input, input.num_topics)
|