add frontend

This commit is contained in:
Dmitry Belyaev 2021-06-15 17:04:36 +03:00
parent 0ab6b70e6f
commit 49789dddc2
Signed by: b4tman
GPG Key ID: 41A00BF15EA7E5F3
3 changed files with 14 additions and 2 deletions

3
.gitmodules vendored
View File

@ -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

1
frontend Submodule

@ -0,0 +1 @@
Subproject commit daadee919029f7dea5d7061b9b73280948ddddbe

View File

@ -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__':