+ add_api_resources
This commit is contained in:
parent
701cbf94e1
commit
05ef983dc2
@ -1,7 +1,27 @@
|
|||||||
from flask_restful import Resource
|
from flask_restful import Resource, Api
|
||||||
|
|
||||||
|
from app.api.apache_restart import ApacheRestartFlag
|
||||||
|
from app.api.config import Config, ConfigTest
|
||||||
|
from app.api.infobases import InfobasesAvailable, InfobasesAll
|
||||||
|
from app.api.module import EnterpriseModule
|
||||||
|
from app.api.publications import Publications, Publication, PublicationURL
|
||||||
|
|
||||||
|
|
||||||
class APIIndex(Resource):
|
class APIIndex(Resource):
|
||||||
def get(self):
|
def get(self):
|
||||||
return ['infobases-available', 'infobases-all', 'publications',
|
return ['infobases-available', 'infobases-all', 'publications',
|
||||||
'module', 'config', 'config-test', 'apache-restart']
|
'module', 'config', 'config-test', 'apache-restart']
|
||||||
|
|
||||||
|
|
||||||
|
def add_api_resources(api: Api) -> None:
|
||||||
|
api.add_resource(InfobasesAvailable, '/infobases-available')
|
||||||
|
api.add_resource(InfobasesAll, '/infobases-all')
|
||||||
|
api.add_resource(Publications, '/publications', '/publications/')
|
||||||
|
api.add_resource(Publication, '/publications/<string:name>')
|
||||||
|
api.add_resource(PublicationURL, '/publications/<string:name>/url')
|
||||||
|
api.add_resource(EnterpriseModule, '/module')
|
||||||
|
api.add_resource(Config, '/config')
|
||||||
|
api.add_resource(ConfigTest, '/config-test')
|
||||||
|
api.add_resource(ApacheRestartFlag, '/apache-restart')
|
||||||
|
api.add_resource(APIIndex, '/')
|
||||||
|
|
||||||
|
@ -2,12 +2,7 @@ from flask import Flask, render_template
|
|||||||
from flask_restful import Api
|
from flask_restful import Api
|
||||||
from flask_cors import CORS
|
from flask_cors import CORS
|
||||||
|
|
||||||
from app.api.apache_restart import ApacheRestartFlag
|
from app.api.index import add_api_resources
|
||||||
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.api.publications import Publications, Publication, PublicationURL
|
|
||||||
from app.glob import get_config, get_manager
|
from app.glob import get_config, get_manager
|
||||||
|
|
||||||
frontend_dir = 'frontend/dist'
|
frontend_dir = 'frontend/dist'
|
||||||
@ -15,16 +10,7 @@ app = Flask(__name__, static_url_path='/', static_folder=frontend_dir, template_
|
|||||||
api = Api(app, '/api/v1/')
|
api = Api(app, '/api/v1/')
|
||||||
cors = CORS(app, resources={r"/api/*": {"origins": "*"}})
|
cors = CORS(app, resources={r"/api/*": {"origins": "*"}})
|
||||||
|
|
||||||
api.add_resource(InfobasesAvailable, '/infobases-available')
|
add_api_resources(api)
|
||||||
api.add_resource(InfobasesAll, '/infobases-all')
|
|
||||||
api.add_resource(Publications, '/publications', '/publications/')
|
|
||||||
api.add_resource(Publication, '/publications/<string:name>')
|
|
||||||
api.add_resource(PublicationURL, '/publications/<string:name>/url')
|
|
||||||
api.add_resource(EnterpriseModule, '/module')
|
|
||||||
api.add_resource(Config, '/config')
|
|
||||||
api.add_resource(ConfigTest, '/config-test')
|
|
||||||
api.add_resource(ApacheRestartFlag, '/apache-restart')
|
|
||||||
api.add_resource(APIIndex, '/')
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
|
Loading…
Reference in New Issue
Block a user