-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.py
47 lines (39 loc) · 1.24 KB
/
main.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
from flask import Flask, request, render_template, jsonify, send_from_directory
from werkzeug.routing import Rule
from config import Config
import os
import lib.scrape as scrape
app = Flask(__name__)
@app.route('/stalk/tiktok', methods=['GET'])
def tiktok_stalk():
username = request.args.get('username')
if not username:
return jsonify({'error': '[!] Both parameter username is required' }), 400
response_data = scrape.tiktok_stalk(username)
response = {
"status": "success",
"author": Config.author,
"code": 200,
"result": response_data
}
return jsonify(response)
def get_routes():
routes = []
for rule in app.url_map.iter_rules():
if rule.endpoint != 'static':
methods = [method for method in rule.methods if method not in ['HEAD', 'OPTIONS']]
methods_str = ', '.join(methods)
route = {
"name": rule.endpoint,
"method": methods_str,
"param": rule.rule,
"url": rule.rule
}
routes.append(route)
return routes
@app.route('/')
def home():
routes = get_routes()
return render_template('index.html', routes=routes)
if __name__ == '__main__':
app.run(debug=True)