-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
47 lines (33 loc) · 942 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from flask import Flask, make_response
from ical import ICal
from scheduler import Scheduler
import logging
import json
logging.basicConfig(level=logging.DEBUG)
def create_app():
with open("team.json") as f:
teams = json.load(f)
ical = ICal(teams)
ical.create_calendar()
scheduler = Scheduler(teams)
scheduler.check_fixtures()
scheduler.start()
app = Flask(__name__)
return app
app = create_app()
@app.route("/ical")
def get_ical():
with open("team.json") as f:
teams = json.load(f)
ical = ICal(teams)
response = make_response(ical.get_calendar())
response.headers["Content-Disposition"] = "attachment; filename=calendar.ics"
return response
if __name__ == "__main__":
with open("team.json") as f:
teams = json.load(f)
ical = ICal(teams)
ical.create_calendar()
scheduler = Scheduler(teams)
scheduler.start()
app.run(debug=True)