From 9cdc2064888cb798e6702c4d7a88d25f6391240f Mon Sep 17 00:00:00 2001 From: krypton-byte Date: Fri, 22 Oct 2021 14:15:19 +0700 Subject: [PATCH] json response --- .../__pycache__/server.cpython-39.pyc | Bin 2796 -> 2906 bytes tiktok_downloader/server.py | 10 ++++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tiktok_downloader/__pycache__/server.cpython-39.pyc b/tiktok_downloader/__pycache__/server.cpython-39.pyc index 0444f1f55d04d462eb5dbc2ffce263300cd3cf84..3cdc0b58724f3d7d6c8725e9c624a0ca09c240e3 100644 GIT binary patch delta 1408 zcmb7E&u<$=6rQ)gcfD&nj_o*Y8sattEPljPYLTocmw*HpK%`QNFV^B&T07pgHMsiHaiT~S2mS$gZ=6CDPV8#FdGC8~cISQbc3)JoYToxe zhvC)X!cV>P{2Kgl{ziQo8f^m@SGhJYL#u6tcH0h}wiD*sIpi7F2X5Pyv)A?lHOL2E zzc4EXOWastbNI(I$>Y|U+Aam9*)q4$b9nACJB4;xGA=S6&r7BvnZmpdyvUa%Rpt6V zYm|PcO*SCYLq7a6YG~)r>vm>+8pNYv6sH#aXn2?)y!08|hr&-~Fo8cDHv%e)6zIu-gTsUS2vHB-b8}*ismqFb;=` zcrpGieWq_ujYREh6X=_LOQJ2&k(iU{ivD7rd2<#i+>~CPTTczN3OI^5mTh{#+IycUgQ#et$Gg10wp4(v)<$&!ojU|=i=fI{XDzNd*q&iVg0a&8WG(1AL2Xi=J z2Kx*T?nM1s-M^TdtjVGpmf#)16A;=(exCC8S;G1-Q@Apx*q`Is19qZeZsAZt|8BBE zajvZ5LC$J(j79e+Q^t!jd@or&WwYALlsRCyg^QPDR3z8_6J5h-Nk+d-u3wENQdhpr z%a7Sadk*dRtWlinR31wzz`So9NFHxb4~e>58Ox<2*Vc0V3QV|Q;DB|((Db?)9nu_iQH@hZU<0X<8+PGAuj1RDg` z2(A;X5!@i4+A}-pg+ZM7;YhqfBq=1`B#`<@9Z4F|M9A#-ze*460;hU1`$3R&!hrYu zEA=<@Od|y{P2i`UDg8KuAXCw~TAUt7_+isV;?EJ7Vu1oKlpzmB`mpBP8{5-Q?}r5s+}@+ delta 1225 zcmZ`&&2JM&6rVS{>;3S0{r!=UFDC(HMFrCeAyrim1@*uIA>{z|0kg_1V8?5_<0Xj5 zX%0c^2`SNXD+l{lsl8PE72JBLinKS5AjE+yhw|PyDk&ifWiCiGq^G+Sn9wXD!?*`d>NkY~c^rCVvWx-B=*f=u9c zy-7C6iBy$M;or!lNLY`xRzAp23c|+75$Q+l09r-GxX5ILr&zG5Uj<99~w)ibR=jFm(fPAfw3_Yu+3$%`y_sDoZr{F`WU*YuBp&cXe)FS zrsciaI&r70&&4b+Bdn(>cU%OB4vONuRGus^F^{7m`;B$B}K!F-b&OF{`Sg_-|L8mE-eym z0w?~_T27ygf3YrKDx%cjvP2nYl%Mc(O}Y7)5?KluJZXb8>@Vg+Ps<9{*uiZd1*P zeK&~OVIVsGaXXa65gK};5B=y~qRU`3Odv=!bUrQK81?aEqJu`a5E!?Bg9|0_K#w<^ zdVJkkFU~^_EYLy!XGxcrXzxn=vvcu_0=l!7PK=K@YB=G8QDU{*eLoD^ZTVIF)>&Kj fNL?eKZB7)UW}1nc=~|%#H9YSOp6FmTPRW7~F)jsr diff --git a/tiktok_downloader/server.py b/tiktok_downloader/server.py index ea71db9..ff6070d 100644 --- a/tiktok_downloader/server.py +++ b/tiktok_downloader/server.py @@ -1,5 +1,5 @@ from tiktok_downloader.mdown import mdown -from flask import Flask, request,render_template +from flask import Flask, request,render_template,Response from . import info_post, snaptik, ssstik, tikmate import json, os app = Flask(__name__, template_folder=os.path.abspath(__file__+'/../templates'), static_folder=os.path.abspath(__file__+'/../static')) @@ -34,7 +34,7 @@ def snapt(path): if not request.args.get('url'): return json.dumps({'msg':'url parameter required'}, indent=4) resp=info_post(request.args['url']) - return json.dumps({ + js=Response(json.dumps({ 'account':{ 'avatar':resp.account.avatar, 'username':resp.account.username, @@ -48,7 +48,9 @@ def snapt(path): 'caption':resp.caption, 'create':resp.create.timestamp(), 'url':resp.url, - 'id':resp.id }, indent=4) + 'id':resp.id }, indent=4)) + js.headers['Content-Type'] = 'application/json' + return js except Exception as e: print(e) return json.dumps({ @@ -67,7 +69,7 @@ def snapt(path): res = tikmate().get_media(request.args['url']) elif path == 'mdown': res = mdown().get_media(request.args['url']) - return json.dumps([{'type':i.type,'url':i.json} for i in res],indent=4) + return Response(json.dumps([{'type':i.type,'url':i.json} for i in res],indent=4), headers={'Content-Type':'application/json'}) except Exception as e: print(e) return json.dumps({