furmeet_events_htmltable2ics/backend_code/app.py

32 lines
788 B
Python
Raw Normal View History

2022-04-24 15:09:38 +00:00
#!/usr/bin/env python3
# -*- encoding: utf-8 -*-
2022-04-24 18:24:34 +00:00
from pathlib import Path
import datetime
2022-04-24 15:50:53 +00:00
import timetable_parser
2022-04-24 18:24:34 +00:00
from flask import Flask, make_response, render_template, request, send_file
2022-04-24 15:09:38 +00:00
app = Flask(__name__, instance_relative_config=True)
@app.route('/', methods=['HEAD', 'OPTIONS', 'GET'])
def index():
2022-04-24 18:24:34 +00:00
return render_template('index.html', datetime=datetime)
@app.route('/favicon.ico', methods=['HEAD', 'OPTIONS', 'GET'])
def favicon():
return send_file(Path('favicon.ico'))
2022-04-24 15:09:38 +00:00
@app.route('/convert.ics', methods=['HEAD', 'OPTIONS', 'GET'])
def convert():
print(request.args.get('url'))
2022-04-24 18:24:34 +00:00
resp_text = 'works?'
resp = make_response(resp_text.encode('utf-8'), 200)
2022-04-24 15:09:38 +00:00
resp.mimetype = 'text/plain'
resp.mimetype_params['charset'] = 'utf-8'
return resp