From 49789dddc2a5140858926f0d21e5547e2cbd65e2 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Tue, 15 Jun 2021 17:04:36 +0300 Subject: [PATCH] add frontend --- .gitmodules | 3 +++ frontend | 1 + pub1c-rest.py | 12 ++++++++++-- 3 files changed, 14 insertions(+), 2 deletions(-) create mode 160000 frontend diff --git a/.gitmodules b/.gitmodules index d5947c4..2e32664 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "webpub1c"] path = webpub1c url = https://github.com/b4tman/webpub1c.git +[submodule "frontend"] + path = frontend + url = ssh://git@gitea.b4tman.ru:4222/b4tman/pub1c-web.frontend.git diff --git a/frontend b/frontend new file mode 160000 index 0000000..daadee9 --- /dev/null +++ b/frontend @@ -0,0 +1 @@ +Subproject commit daadee919029f7dea5d7061b9b73280948ddddbe diff --git a/pub1c-rest.py b/pub1c-rest.py index e696fa8..fbe4716 100644 --- a/pub1c-rest.py +++ b/pub1c-rest.py @@ -4,7 +4,7 @@ from typing import List, Optional, Dict import traceback import yaml -from flask import Flask, g +from flask import Flask, g, render_template from flask_restful import Resource, Api, reqparse, abort from flask_cors import CORS from pathvalidate import is_valid_filepath @@ -339,7 +339,8 @@ class APIIndex(Resource): 'module', 'config', 'config-test', 'apache-restart'] -app = Flask(__name__) +frontend_dir = 'frontend/dist' +app = Flask(__name__, static_url_path='/', static_folder=frontend_dir, template_folder=frontend_dir) api = Api(app, '/api/v1/') cors = CORS(app, resources={r"/api/*": {"origins": "*"}}) @@ -354,9 +355,16 @@ api.add_resource(ConfigTest, '/config-test') api.add_resource(ApacheRestartFlag, '/apache-restart') api.add_resource(APIIndex, '/') + +@app.route('/') +def index(): + return index_content + + with app.app_context(): get_config() get_webpub1c() + index_content = render_template("index.html") if __name__ == '__main__':