From 58f0344d828bd935cb091832756b34ca50419123 Mon Sep 17 00:00:00 2001 From: Melmon Date: Sun, 20 Jun 2021 01:39:02 +0100 Subject: [PATCH] added simple index page --- atch/__init__.py | 3 ++- atch/index.py | 14 ++++++++++++++ atch/templates/index.html | 17 +++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 atch/index.py create mode 100644 atch/templates/index.html diff --git a/atch/__init__.py b/atch/__init__.py index be65e28..cb1c4bf 100644 --- a/atch/__init__.py +++ b/atch/__init__.py @@ -1,5 +1,5 @@ import os -from . import db, board, thread +from . import db, board, thread, index from flask import Flask, render_template, current_app @@ -27,6 +27,7 @@ def create_app(test_config=None): db.init_app(app) app.register_blueprint(board.bp) app.register_blueprint(thread.bp) + app.register_blueprint(index.bp) app.register_error_handler(404, four_oh_four) return app diff --git a/atch/index.py b/atch/index.py new file mode 100644 index 0000000..ac728b4 --- /dev/null +++ b/atch/index.py @@ -0,0 +1,14 @@ +from flask import Blueprint, flash, g, redirect, render_template, request, session, url_for, abort, jsonify +from atch.db import get_db + +bp = Blueprint('index', __name__) + + +@bp.route('/') +def index(): + db = get_db() + boards = db.execute( + 'SELECT uri, name FROM boards ORDER BY uri' + ).fetchall() + + return render_template('index.html', boards=boards) diff --git a/atch/templates/index.html b/atch/templates/index.html new file mode 100644 index 0000000..2d999cd --- /dev/null +++ b/atch/templates/index.html @@ -0,0 +1,17 @@ +{% extends "base.html" %} + +{% block header %} +

{% block title %}Welcome to @channel{% endblock %}

+{% endblock %} + +{% block content %} + @channel is a simple message board, letting you create and reply to threads about all sorts of different things, with markdown support coming soon. Feel free to browse the boards below. +
+ {% for b in boards %} + + {% endfor %} +
+{% endblock %} + +{% block scripts %} +{% endblock %} \ No newline at end of file -- 2.38.5