ka1kuk commited on
Commit
9d9aae5
1 Parent(s): 0cda19c

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +9 -4
main.py CHANGED
@@ -28,16 +28,21 @@ def hi(hello: str):
28
  return {"text": hello}
29
 
30
 
 
 
 
 
 
 
31
  @app.post('/linlada')
32
  async def generate_image_route(request: Request):
33
  data = await request.json()
34
  prompt = data['prompt']
35
- loop = asyncio.new_event_loop()
36
- asyncio.set_event_loop(loop)
37
- result = loop.run_until_complete(generate(prompt))
38
- loop.close()
39
  return result
40
 
 
41
  @app.get('/chat/{prompt}')
42
  def generate_image_route(prompt: str):
43
  loop = asyncio.new_event_loop()
 
28
  return {"text": hello}
29
 
30
 
31
+ @app.post('/linlada')
32
+ from fastapi import FastAPI, Request
33
+ import asyncio
34
+
35
+ app = FastAPI()
36
+
37
  @app.post('/linlada')
38
  async def generate_image_route(request: Request):
39
  data = await request.json()
40
  prompt = data['prompt']
41
+ loop = asyncio.get_running_loop()
42
+ result = await loop.run_until_complete(generate(prompt))
 
 
43
  return result
44
 
45
+
46
  @app.get('/chat/{prompt}')
47
  def generate_image_route(prompt: str):
48
  loop = asyncio.new_event_loop()