Delete app.py
Browse files
app.py
DELETED
@@ -1,63 +0,0 @@
|
|
1 |
-
from flask import Flask, render_template, jsonify
|
2 |
-
import requests
|
3 |
-
import json
|
4 |
-
|
5 |
-
app = Flask(__name__)
|
6 |
-
|
7 |
-
API_URL = "https://badimo.nyc3.digitaloceanspaces.com/trade/frequency/snapshot/month/latest.json"
|
8 |
-
|
9 |
-
@app.route('/')
|
10 |
-
def index():
|
11 |
-
return render_template('index.html')
|
12 |
-
|
13 |
-
@app.route('/api/data')
|
14 |
-
def get_data():
|
15 |
-
try:
|
16 |
-
response = requests.get(API_URL)
|
17 |
-
response.raise_for_status()
|
18 |
-
data = response.json()
|
19 |
-
|
20 |
-
# Add additional derived metrics
|
21 |
-
for item in data:
|
22 |
-
item['RarityScore'] = round(item['TimesTraded'] / item['UniqueCirculation'] if item['UniqueCirculation'] > 0 else 0, 2)
|
23 |
-
|
24 |
-
return jsonify(data)
|
25 |
-
except Exception as e:
|
26 |
-
return jsonify({"error": str(e)}), 500
|
27 |
-
|
28 |
-
@app.route('/api/stats')
|
29 |
-
def get_stats():
|
30 |
-
try:
|
31 |
-
response = requests.get(API_URL)
|
32 |
-
response.raise_for_status()
|
33 |
-
data = response.json()
|
34 |
-
|
35 |
-
# Generate stats by type
|
36 |
-
stats_by_type = {}
|
37 |
-
for item in data:
|
38 |
-
item_type = item['Type']
|
39 |
-
if item_type not in stats_by_type:
|
40 |
-
stats_by_type[item_type] = {
|
41 |
-
'count': 0,
|
42 |
-
'totalTraded': 0,
|
43 |
-
'totalCirculation': 0,
|
44 |
-
'averageDemand': 0
|
45 |
-
}
|
46 |
-
|
47 |
-
stats_by_type[item_type]['count'] += 1
|
48 |
-
stats_by_type[item_type]['totalTraded'] += item['TimesTraded']
|
49 |
-
stats_by_type[item_type]['totalCirculation'] += item['UniqueCirculation']
|
50 |
-
|
51 |
-
# Calculate averages
|
52 |
-
for type_key in stats_by_type:
|
53 |
-
if stats_by_type[type_key]['totalCirculation'] > 0:
|
54 |
-
stats_by_type[type_key]['averageDemand'] = round(
|
55 |
-
stats_by_type[type_key]['totalTraded'] / stats_by_type[type_key]['totalCirculation'], 2
|
56 |
-
)
|
57 |
-
|
58 |
-
return jsonify(stats_by_type)
|
59 |
-
except Exception as e:
|
60 |
-
return jsonify({"error": str(e)}), 500
|
61 |
-
|
62 |
-
if __name__ == '__main__':
|
63 |
-
app.run(host='0.0.0.0', port=7860, debug=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|