Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
@@ -177,6 +177,17 @@ async def get_completion(payload: Payload):
|
|
177 |
raise HTTPException(status_code=500, detail=f"An unexpected error occurred: {e}")
|
178 |
|
179 |
return StreamingResponse(stream_generator(payload_dict), media_type="application/json")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
180 |
@app.on_event("startup")
|
181 |
async def startup_event():
|
182 |
print("API endpoints:")
|
|
|
177 |
raise HTTPException(status_code=500, detail=f"An unexpected error occurred: {e}")
|
178 |
|
179 |
return StreamingResponse(stream_generator(payload_dict), media_type="application/json")
|
180 |
+
@app.get("/playground", response_class=HTMLResponse)
|
181 |
+
async def playground():
|
182 |
+
# Open and read the content of playground.html (in the same folder as the app)
|
183 |
+
file_path = "playground.html"
|
184 |
+
|
185 |
+
try:
|
186 |
+
with open(file_path, "r") as file:
|
187 |
+
html_content = file.read()
|
188 |
+
return HTMLResponse(content=html_content)
|
189 |
+
except FileNotFoundError:
|
190 |
+
return HTMLResponse(content="<h1>playground.html not found</h1>", status_code=404)
|
191 |
@app.on_event("startup")
|
192 |
async def startup_event():
|
193 |
print("API endpoints:")
|