move config and module api

This commit is contained in:
Dmitry Belyaev 2021-10-07 13:59:51 +03:00
parent 83d6388e35
commit 24d3f50e29
Signed by: b4tman
GPG Key ID: 41A00BF15EA7E5F3
3 changed files with 38 additions and 30 deletions

14
app/api/config.py Normal file
View File

@ -0,0 +1,14 @@
from flask_restful import Resource
from app.glob import get_config, get_manager
class Config(Resource):
def get(self):
return get_config()
class ConfigTest(Resource):
def get(self):
manager = get_manager()
return manager.check()

22
app/api/module.py Normal file
View File

@ -0,0 +1,22 @@
from flask_restful import Resource, abort
from app.glob import get_manager
class EnterpriseModule(Resource):
def get(self):
manager = get_manager()
if not manager.has_module():
abort(404, message='not found')
return {
'message': 'found'
}
def put(self):
manager = get_manager()
if manager.has_module():
return '', 304
manager.add_module()
return {
'message': 'success'
}

View File

@ -6,8 +6,10 @@ from flask_restful import Resource, Api, reqparse, abort
from flask_cors import CORS
from app.api.apache_restart import ApacheRestartFlag
from app.api.config import Config, ConfigTest
from app.api.index import APIIndex
from app.api.infobases import InfobasesAvailable, InfobasesAll
from app.api.module import EnterpriseModule
from app.glob import get_config, get_manager
from app.utils import validate_url
@ -26,17 +28,6 @@ remove_parser = reqparse.RequestParser()
remove_parser.add_argument('force', type=bool, default=False)
class Config(Resource):
def get(self):
return get_config()
class ConfigTest(Resource):
def get(self):
manager = get_manager()
return manager.check()
class Publications(Resource):
def get(self) -> List[Dict[str, str]]:
manager = get_manager()
@ -113,25 +104,6 @@ class PublicationURL(Resource):
return {'message': 'success', 'name': name, 'url': url}
class EnterpriseModule(Resource):
def get(self):
manager = get_manager()
if not manager.has_module():
abort(404, message='not found')
return {
'message': 'found'
}
def put(self):
manager = get_manager()
if manager.has_module():
return '', 304
manager.add_module()
return {
'message': 'success'
}
frontend_dir = 'frontend/dist'
app = Flask(__name__, static_url_path='/', static_folder=frontend_dir, template_folder=frontend_dir)
api = Api(app, '/api/v1/')