Reputation: 1085
Hi I need to process a remote .ical file from another server on my own server and hand it back to the requesting user.
So what I need to do is:
I'd know how to do this with php:
header('Content-type: text/calendar; charset=utf-8');
header('Content-Disposition: inline; filename=calendar.ics');
echo $ical;
exit;
But how to do the same thing in python?
Upvotes: 0
Views: 327
Reputation: 129754
Well, as with anything web-related, you start with a WSGI application.
def app(environ, start_response):
calendar = get_processed_file()
start_response('200 OK', [
('Content-Type', 'text/icalendar; charset=utf-8'),
('Content-Disposition', 'inline; filename=calendar.ics'),
])
yield calendar
Then to deploy, you use a handler, e.g. plain CGI would be
import wsgiref
wsgiref.CGIHandler().run(app)
See http://www.wsgi.org/ for more materials about WSGI.
Upvotes: 1