from fastapi import FastAPI
from fastapi import Request
from fastapi import Form
import urllib
import sys
import os
import codecs
import html

app = FastAPI()

@app.post("/items")
async def read_item(search_query: str = Form(...)):
    unq=html.unescape(search_query)
#    unq=search_query.decode("utf-8")
    print(unq)
    fw=codecs.open('/tmp/script.txt','w','utf-8')
    fw.write(unq)
    fw.close()
    print(search_query)
    os.chdir('/home/jared/gitlab/spokesgirl_tests/apis')
    os.system('python3.7 proc_video.py &')
    return {"item_id": "Please use Telegram to get notifications. "}


@app.get("/")
async def root():
    return {"message": "Hello World"}

