-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFRiCal.py
More file actions
33 lines (23 loc) · 761 Bytes
/
FRiCal.py
File metadata and controls
33 lines (23 loc) · 761 Bytes
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
from flask import Flask, request, make_response, render_template
import urllib2
import convert
import logging
logging.basicConfig(level=logging.DEBUG)
app = Flask(__name__)
BASE_URL = 'https://urnik.fri.uni-lj.si'
@app.route('/')
def index():
return render_template('index.html')
@app.route('/allocations', defaults={'path': ''})
@app.route('/<path:path>/allocations')
def do_convert(path):
url = BASE_URL + request.full_path
logging.debug(url)
f = urllib2.urlopen(url)
ical = convert.convert(f.read())
resp = make_response(ical)
resp.headers['Content-type'] = 'text/calendar; charset=utf-8'
resp.headers['Content-Disposition'] = 'inline; filename=calendar.ics'
return resp
if __name__ == '__main__':
app.run()