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 from threads_with_posts import open_threads from arango import ArangoClient import socket app = Flask(__name__) assets = Environment(app) css = Bundle("src/*.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() arango_client = ArangoClient(hosts='https://arango.vdk2ch.ru') db = arango_client.db('board1', username='root', password='stolendick527') # предполагается что меняться список будет весьма редко, поэтому подхватываем при лишь при перезапуске boards0 = db.collection('boards') board_list = [ k['_key'] for k in boards0] @app.route('/liveness') def healthx(): return "

Liveness check completed

" @app.route('/readiness') def healthz(): return "

Readiness check completed

" @app.route("/") def homepage(): docker_short_id = socket.gethostname() return render_template("main-page.html", host_id=docker_short_id, boards=board_list) @app.route("/boards/") def page_board(board_id): b_threads = [ open_threads[thread_id] for thread_id in open_threads if thread_id in threads_lists[board_id]] return render_template("board.html", board_id=board_id, boards=board_list, board_threads=b_threads) @app.route("/db_posts") def page_posts_from_db(): postos = db.collection('posts') postos = [ p for p in postos] return render_template("interactive-posts.html", postos=postos) # @app.route('/post_my_post', method=['POST']) # def post_a_post(): # pass # @app.route('/post_my_file', method=['POST']) # def post_a_file(): # pass ### 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')