iShare commited on
Commit
0f7b3d4
1 Parent(s): a361f2d

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +7 -6
main.py CHANGED
@@ -33,12 +33,12 @@ class ChatRequest(BaseModel):
33
  target_url: str
34
  #似乎必须要有这个class定义???
35
 
36
- @app.post('/')
37
- async def home_api(request: Request):
38
- data = await request.json()
39
- target_url = data['target_url']
40
- print(target_url)
41
- return {"Message": "FastAPI Home API Deploy Success on HF"}
42
 
43
  @app.post('/api/chat')
44
  async def chat(request: Request, chat_request: ChatRequest):
@@ -59,6 +59,7 @@ async def chat(request: Request, chat_request: ChatRequest):
59
  print("AI Summarization: " + result)
60
  #return {'response': result} #FastAPI方式下,这个返回形式,有问题?
61
  return JSONResponse({'response': result})
 
62
  except Exception as e:
63
  err_msg = "Wrong URL or URL not parsable."
64
  print(err_msg)
 
33
  target_url: str
34
  #似乎必须要有这个class定义???
35
 
36
+ #@app.post('/')
37
+ #async def home_api(request: Request):
38
+ # data = await request.json()
39
+ # target_url = data['target_url']
40
+ # print(target_url)
41
+ # return {"Message": "FastAPI Home API Deploy Success on HF"}
42
 
43
  @app.post('/api/chat')
44
  async def chat(request: Request, chat_request: ChatRequest):
 
59
  print("AI Summarization: " + result)
60
  #return {'response': result} #FastAPI方式下,这个返回形式,有问题?
61
  return JSONResponse({'response': result})
62
+ #对比FlaskAPI的:return jsonify({'response': result}),JSONResponse vs jsonify(都需要相应的from ... import ...)
63
  except Exception as e:
64
  err_msg = "Wrong URL or URL not parsable."
65
  print(err_msg)