flask-htmx-board1/app.py
Simple_Not a9cabbe7d8
All checks were successful
continuous-integration/drone/push Build is passing
some structure
2023-07-03 23:18:37 +10:00

73 lines
1.5 KiB
Python

from flask import Flask, render_template, request
from flask_assets import Bundle, Environment
from todo import todos
from boards import board_list
from threads import threads_lists
import socket
app = Flask(__name__)
assets = Environment(app)
#css = Bundle("src/main.css", output="dist/main.css")
# https://unpkg.com/htmx.org
js = Bundle("src/*.js", output="dist/main.js")
#assets.register("css", css)
assets.register("js", js)
#css.build()
js.build()
@app.route('/liveness')
def healthx():
return "<h1><center>Liveness check completed</center><h1>"
@app.route('/readiness')
def healthz():
return "<h1><center>Readiness check completed</center><h1>"
@app.route("/")
def homepage():
docker_short_id = socket.gethostname()
return render_template("main-page.html", host_id=docker_short_id, boards=board_list)
### stolen
@app.route("/boards/<board_id>")
def page_board(board_id):
return render_template("board.html", boards=board_list, board_threads=threads_lists[board_id])
### stolen
@app.route("/todo")
def page_todo():
return render_template("page1.html")
@app.route("/search", methods=["POST"])
def search_todo():
search_term = request.form.get("search")
if not len(search_term):
return render_template("todo.html", todos=[])
res_todos = []
for todo in todos:
if search_term in todo["title"]:
res_todos.append(todo)
return render_template("todo.html", todos=res_todos)
### /stolen
if __name__ == "__main__":
app.run(debug=True, host='0.0.0.0')