2023-07-01 20:29:27 +10:00
|
|
|
from flask import Flask, render_template, request
|
|
|
|
from flask_assets import Bundle, Environment
|
|
|
|
|
2023-07-01 22:41:34 +10:00
|
|
|
from todo import todos
|
2023-07-01 20:29:27 +10:00
|
|
|
|
|
|
|
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()
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-07-03 22:46:40 +10:00
|
|
|
|
|
|
|
@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>"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-07-01 20:29:27 +10:00
|
|
|
@app.route("/")
|
|
|
|
def homepage():
|
2023-07-03 22:41:49 +10:00
|
|
|
return render_template("main-page.html")
|
|
|
|
|
|
|
|
@app.route("/todo")
|
|
|
|
def page_todo():
|
2023-07-01 20:29:27 +10:00
|
|
|
return render_template("page1.html")
|
|
|
|
|
|
|
|
|
2023-07-01 22:41:34 +10:00
|
|
|
@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)
|
|
|
|
|
|
|
|
|
2023-07-01 20:29:27 +10:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2023-07-02 00:46:17 +10:00
|
|
|
app.run(debug=True, host='0.0.0.0')
|