main.py 807 B

123456789101112131415161718192021222324252627282930313233343536
  1. from fastapi import FastAPI
  2. from fastapi import Request
  3. from fastapi import Form
  4. import urllib
  5. import sys
  6. import os
  7. import codecs
  8. import html
  9. app = FastAPI()
  10. @app.post("/items")
  11. async def read_item(search_query: str = Form(...)):
  12. unq=html.unescape(search_query)
  13. # unq=search_query.decode("utf-8")
  14. print(unq)
  15. fw=codecs.open('/tmp/script.txt','w','utf-8')
  16. fw.write(unq)
  17. fw.close()
  18. print(search_query)
  19. os.chdir('/home/jared/gitlab/spokesgirl_tests/apis')
  20. os.system('python3.7 proc_video.py &')
  21. return {"item_id": "Please use Telegram to get notifications. "}
  22. @app.post("/tts")
  23. async def tts(search_query: str = Form(...)):
  24. return {"item_id": "Please use Telegram to get notifications. "}
  25. @app.get("/")
  26. async def root():
  27. return {"message": "Hello World"}