forked from B1gM8c/tiktok
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TikTokWeb.py
57 lines (43 loc) · 1.2 KB
/
TikTokWeb.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@Description:TikTok.py
@Date :2023/01/27 19:36:18
@Author :imgyh
@version :1.0
@Github :https://github.com/imgyh
@Mail :admin@imgyh.com
-------------------------------------------------
Change Log :
-------------------------------------------------
'''
from flask import *
from TikTok import TikTok
def work(share_link):
tk = TikTok()
url = tk.getShareLink(share_link)
key_type, key = tk.getKey(url)
datanew, dataraw = tk.getAwemeInfo(key)
return datanew
app = Flask(__name__)
# 设置编码
app.config['JSON_AS_ASCII'] = False
@app.route("/douyin", methods=["POST"])
def douyin():
usefuldict = {}
if request.method == "POST":
result = request.form
else:
usefuldict["status_code"] = 500
return jsonify(usefuldict)
try:
usefuldict = work(result["share_link"])
usefuldict["status_code"] = 200
except Exception as error:
usefuldict["status_code"] = 500
return jsonify(usefuldict)
@app.route("/", methods=["GET"])
def index():
return render_template("index.html")
if __name__ == "__main__":
app.run(debug=False, host="0.0.0.0", port=5000)