-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
30 lines (26 loc) · 801 Bytes
/
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
from flask import Flask, request, jsonify
from marketdata import item_data, get_hashname
app = Flask(__name__)
@app.route('/api/weapon', methods=['POST'])
def get_item_data():
gun = request.json['gun']
skin = request.json['skin']
wear = request.json['wear']
stat = request.json['stat']
hashname = get_hashname(gun, skin, wear, stat)
try:
data = item_data(hashname)
return jsonify(data)
except:
return jsonify({"error": "Item data not available"})
@app.route('/api/case', methods=['POST'])
def get_case_data():
case = request.json['case']
hashname = case.replace(' ', '%20')
try:
data = item_data(hashname)
return jsonify(data)
except:
return jsonify({"error": "Item data not available"})
if __name__ == '__main__':
app.run(debug=True)