-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainapp.py
106 lines (81 loc) · 3.14 KB
/
mainapp.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
from flask import Flask, render_template, send_from_directory, request
from logging import FileHandler, WARNING
from flask import abort
app = Flask(__name__)
file_handler = FileHandler('errorlog.txt')
file_handler.setLevel(WARNING)
@app.route('/', methods=['GET', 'POST'])
def home_page():
if request.method == "POST":
day = request.form.get("day")
month = request.form.get("month")
year = request.form.get("year")
source = request.form.get("source")
date = year+month+day
return send_from_directory(f"./datasheets/{source}_Api", date+"_"+source+"_All_Data.csv", as_attachment=True)
return render_template("index.html")
@app.route('/googleadmob/<path:path>', methods=['GET'])
def fetch_admob(path):
try:
return send_from_directory("./datasheets/Google_Admob_Api/", path, as_attachment=True)
except FileNotFoundError:
abort(404)
@app.route('/googleads/<path:path>', methods=['GET'])
def fetch_ads(path):
try:
return send_from_directory("./datasheets/Google_Ads_Api/", path, as_attachment=True)
except FileNotFoundError:
abort(404)
@app.route('/facebookads/<path:path>', methods=['GET'])
def fetch_facebook(path):
try:
return send_from_directory("./datasheets/Facebook_Ads_Api/", path, as_attachment=True)
except FileNotFoundError:
abort(404)
@app.route('/googleanalytics/<path:path>', methods=['GET'])
def fetch_analytics(path):
try:
return send_from_directory("./datasheets/Google_Analytics_Api/", path, as_attachment=True)
except FileNotFoundError:
abort(404)
@app.route('/combinedbyapp/<path:path>', methods=['GET'])
def combine_by_app(path):
print(path)
try:
return send_from_directory("./datasheets/Combined_Data_By_App/", path, as_attachment=True)
except FileNotFoundError:
print("File not found")
abort(404)
@app.route('/combinedbycountry/<path:path>', methods=['GET'])
def combine_by_country(path):
try:
return send_from_directory("./datasheets/Combined_Data_By_Country/", path, as_attachment=True)
except FileNotFoundError:
abort(404)
@app.route('/playconsoledata/<path:path>', methods=['GET'])
def playconsole_by_country(path):
try:
return send_from_directory("./datasheets/PlayConsole_Api/", path, as_attachment=True)
except FileNotFoundError:
abort(404)
@app.route('/combinedappdatabydate/<path:path>', methods=['GET'])
def fetch_app_by_date(path):
try:
return send_from_directory("./datasheets/Combined_Data_By_App/", path, as_attachment=True)
except:
abort(404)
@app.route('/combinedcountrydatabydate/<path:path>', methods=['GET'])
def fetch_country_by_date(path):
try:
return send_from_directory("./datasheets/Combined_Data_By_Country/", path, as_attachment=True)
except:
abort(404)
@app.route('/combinedalldatabydate/<path:path>', methods=['GET'])
def all_data_by_date(path):
try:
return send_from_directory("./datasheets/Combined_Data_By_Date/", path, as_attachment=True)
except:
abort(404)
if __name__ == "__main__":
app.debug = True
app.run(host='127.0.0.1')