diff --git a/tiktok_downloader/__pycache__/server.cpython-39.pyc b/tiktok_downloader/__pycache__/server.cpython-39.pyc index 0444f1f..3cdc0b5 100644 Binary files a/tiktok_downloader/__pycache__/server.cpython-39.pyc and b/tiktok_downloader/__pycache__/server.cpython-39.pyc differ 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({