From ed267e065fd31867162a00d64962f4089511914e Mon Sep 17 00:00:00 2001 From: nikili0n Date: Tue, 26 Sep 2023 00:15:04 +0300 Subject: [PATCH] up link and change to post --- src/web/main.py | 5 ++--- src/web/templates/index.html | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/web/main.py b/src/web/main.py index 90db6c2..2a3fae7 100644 --- a/src/web/main.py +++ b/src/web/main.py @@ -148,7 +148,7 @@ async def download_video(file_path): return StreamingResponse(iterfile(), media_type="video/mp4") -@app.get('/check/', response_class=FileResponse, status_code=200) +@app.post('/check/', response_class=FileResponse, status_code=200) async def download_video(request: Request, link: str): try: red = RedisClient() @@ -188,5 +188,4 @@ async def download_video(request: Request, link: str): except Exception as ex: print(ex) -if __name__ == '__main__': - uvicorn.run("src.web.main:app", host="0.0.0.0", log_level="info") +uvicorn.run("src.web.main:app", host="0.0.0.0", log_level="info") diff --git a/src/web/templates/index.html b/src/web/templates/index.html index 7d6c4e1..e8e5bd2 100644 --- a/src/web/templates/index.html +++ b/src/web/templates/index.html @@ -93,7 +93,7 @@ const link = document.getElementById("link").value const xhr2 = new XMLHttpRequest(); // TODO: скорректировать ссылку, она должна быть относительной - xhr2.open('GET', 'http://'+document.location.host+'/check/?link=' + link); + xhr2.open('POST', 'http://'+document.location.host+'/check'); xhr2.responseType = 'json'; xhr2.onload = function() { // TODO: добавить обработку исключений и всех возможных кодов в ответе @@ -112,7 +112,7 @@ document.forms.download.querySelector('.submit-spinner').classList.add('submit-spinner_hide'); }; }; - xhr2.send() + xhr2.send(link) }