-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
88 lines (59 loc) · 2.21 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
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
import argparse
import os
import json
from flask_sitemap import Sitemap
from flask import Flask, render_template, send_from_directory
from utils.plot_functions import create_plot_for_category
app = Flask(__name__)
ext = Sitemap(app=app)
with open("track_stats.json", "r") as f:
data = json.load(f)
@ext.register_generator
def index():
yield 'home', {}, "", "", 1
yield 'graphs', {}, "", "daily", 0.8
yield 'raw_stats', {}, "", "daily", 0.2
@app.route('/')
def home():
return render_template('home.html')
@app.route('/graphs')
def graphs():
categories = ['badges', 'furnis', 'clothes', 'effects']
plots = [create_plot_for_category(data, category) for category in categories]
indexed_plots = list(enumerate(plots))
return render_template('graphs.html', indexed_plots=indexed_plots, categories=categories)
@app.route('/favicon.ico')
def favicon():
return send_from_directory(os.path.join(app.root_path, 'img'), 'H.ico', mimetype='image/vnd.microsoft.icon')
@app.route("/raw_stats")
def raw_stats():
return data
@app.route("/robots.txt")
def robots():
return send_from_directory(app.template_folder, 'robots.txt')
@app.route("/img/<path:path>")
def send_img(path):
return send_from_directory(os.path.join(app.root_path, 'img'), path)
@app.route("/google06cec27a8c7f7b33.html")
def google():
return render_template('google06cec27a8c7f7b33.html')
@app.route("/yandex_67dde65cedc0b4cd.html")
def yandex():
return render_template('yandex_67dde65cedc0b4cd.html')
@app.route("/ed949a7d7fc84afb88038376ff960d21.txt")
def index_now():
return render_template('ed949a7d7fc84afb88038376ff960d21.txt')
@app.route("/.well-known/<path:path>")
def well_known(path):
chemin_fichier = os.path.join(app.root_path, '.well-known', path)
with open(chemin_fichier, 'r') as f:
contenu = f.read()
return contenu, 200, {'Content-Type': 'text/plain'}
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Run Flask application.')
parser.add_argument('--debug', action='store_true', help='Run in debug mode')
args = parser.parse_args()
if args.debug:
app.run(debug=True)
else:
app.run(host='0.0.0.0', port=80)