Files
propedal-planner/app.py
2022-06-12 11:16:22 +02:00

42 lines
910 B
Python

import calendar_interface
import sqlite3
from flask import Flask, render_template, request, url_for, flash, redirect
from werkzeug.exceptions import abort
def get_db_connection():
conn = sqlite3.connect('database.db')
conn.row_factory = sqlite3.Row
return conn
def get_post(post_id):
conn = get_db_connection()
post = conn.execute('SELECT * FROM posts WHERE id = ?',
(post_id,)).fetchone()
conn.close()
if post is None:
abort(404)
return post
app = Flask(__name__)
# app.config['SECRET_KEY'] = 'hello'
@app.route('/')
def index():
events = calendar_interface.get_all_calendar_events()
if post is None:
abort(404)
else:
return render_template('index.html', events=events)
@app.route('/<int:event_id>')
def post(post_id):
post = get_post(post_id)
return render_template('show_event.html', post=post)