forked from JixiangGao/ChainManAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.py
138 lines (108 loc) · 3.13 KB
/
api.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# -*- coding: utf-8 -*-
# !flask/bin/python
from flask import Flask, jsonify
from flask import request
import sql
from werkzeug.routing import BaseConverter
class RegexConverter(BaseConverter):
def __init__(self, map, *args):
self.map = map
self.regex = args[0]
app = Flask(__name__)
app.config['JSON_AS_ASCII'] = False # 让支持jsonify中文
app.url_map.converters['regex'] = RegexConverter
@app.route('/get_coins', methods=['GET'])
def get_coins():
mysql = sql.sql()
result = mysql.get_coins(request.args)
mysql.db_close()
return jsonify(result)
@app.route('/get_commits_num')
def get_commits_num():
mysql = sql.sql()
result = mysql.get_commits_num(request.args)
mysql.db_close()
return jsonify(result)
@app.route('/get_last')
def get_last():
mysql = sql.sql()
result = mysql.get_last(request.args)
mysql.db_close()
return jsonify(result)
@app.route('/get_rank')
def get_rank():
mysql = sql.sql()
result = mysql.get_rank(request.args)
mysql.db_close()
return jsonify(result)
@app.route('/get_frequency')
def get_frequency():
mysql = sql.sql()
result = mysql.get_frequency(request.args)
mysql.db_close()
return jsonify(result)
@app.route('/login')
def login():
mysql = sql.sql()
result = mysql.login(request.args)
mysql.db_close()
return jsonify(result)
@app.route('/get_personal_coins')
def get_personal_coins():
mysql = sql.sql()
result = mysql.get_personal_coins(request.args)
mysql.db_close()
return jsonify(result)
@app.route('/insert_personal_coin')
def insert_personal_coin():
mysql = sql.sql()
result = mysql.insert_personal_coin(request.args)
mysql.db_close()
return jsonify(result)
@app.route('/delete_personal_coin')
def delete_personal_coin():
mysql = sql.sql()
result = mysql.delete_personal_coin(request.args)
mysql.db_close()
return jsonify(result)
@app.route('/get_coins_list')
def get_coins_list():
mysql = sql.sql()
result = mysql.get_coins_list(request.args)
mysql.db_close()
return jsonify(result)
@app.route('/coinmarketcap/<regex(".*"):url>')
def coinmarketcap(url):
mysql = sql.sql()
result = mysql.coinmarketcap(url, request.args)
mysql.db_close()
return jsonify(result)
@app.route('/get_coin_detail')
def get_coin_detail():
mysql = sql.sql()
result = mysql.get_coin_detail(request.args)
mysql.db_close()
return jsonify(result)
@app.route('/get_coin_sites')
def get_coin_sites():
mysql = sql.sql()
result = mysql.get_coin_sites(request.args)
mysql.db_close()
return jsonify(result)
@app.route('/get_login_log')
def get_login_log():
mysql = sql.sql()
result = mysql.get_login_log(request.args)
mysql.db_close()
return jsonify(result)
@app.route('/get_user_coins_history')
def get_user_coins_history():
mysql = sql.sql()
result = mysql.get_user_coins_history(request.args)
mysql.db_close()
return jsonify(result)
if __name__ == '__main__':
app.run(host='0.0.0.0', debug=True, ssl_context=(
'ssl/1_www.banbaofruit.com_bundle.crt',
'ssl/2_www.banbaofruit.com.key'
))