move api index and apache_restart
This commit is contained in:
parent
8eef627c2e
commit
f5680564d2
0
app/api/__init__.py
Normal file
0
app/api/__init__.py
Normal file
29
app/api/apache_restart.py
Normal file
29
app/api/apache_restart.py
Normal file
@ -0,0 +1,29 @@
|
||||
import os
|
||||
|
||||
from flask_restful import Resource, abort
|
||||
|
||||
from app.glob import get_config
|
||||
|
||||
apache_restart_flagfile = 'restart_apache'
|
||||
|
||||
|
||||
class ApacheRestartFlag(Resource):
|
||||
def get(self):
|
||||
cfg = get_config()
|
||||
flagfile = cfg.get('apache_restart_flagfile', apache_restart_flagfile)
|
||||
if not os.path.isfile(flagfile):
|
||||
abort(404, message='not found')
|
||||
return {
|
||||
'message': 'found'
|
||||
}
|
||||
|
||||
def put(self):
|
||||
cfg = get_config()
|
||||
flagfile = cfg.get('apache_restart_flagfile', apache_restart_flagfile)
|
||||
if os.path.isfile(flagfile):
|
||||
return '', 304
|
||||
with open(flagfile, 'a'):
|
||||
pass
|
||||
return {
|
||||
'message': 'success'
|
||||
}
|
7
app/api/index.py
Normal file
7
app/api/index.py
Normal file
@ -0,0 +1,7 @@
|
||||
from flask_restful import Resource
|
||||
|
||||
|
||||
class APIIndex(Resource):
|
||||
def get(self):
|
||||
return ['infobases-available', 'infobases-all', 'publications',
|
||||
'module', 'config', 'config-test', 'apache-restart']
|
@ -1,4 +1,3 @@
|
||||
import os
|
||||
from typing import List, Dict
|
||||
import traceback
|
||||
|
||||
@ -6,13 +5,13 @@ from flask import Flask, render_template
|
||||
from flask_restful import Resource, Api, reqparse, abort
|
||||
from flask_cors import CORS
|
||||
|
||||
from app.api.apache_restart import ApacheRestartFlag
|
||||
from app.api.index import APIIndex
|
||||
from app.glob import get_config, get_manager
|
||||
from app.manager import infobase_data_blank
|
||||
from app.utils import validate_url
|
||||
from brackets import get_infobases as br_get_infobases
|
||||
|
||||
apache_restart_flagfile = 'restart_apache'
|
||||
|
||||
pub_parser = reqparse.RequestParser()
|
||||
pub_parser.add_argument('url', type=str)
|
||||
pub_parser.add_argument('file', type=str, default='')
|
||||
@ -166,34 +165,6 @@ class EnterpriseModule(Resource):
|
||||
}
|
||||
|
||||
|
||||
class ApacheRestartFlag(Resource):
|
||||
def get(self):
|
||||
cfg = get_config()
|
||||
flagfile = cfg.get('apache_restart_flagfile', apache_restart_flagfile)
|
||||
if not os.path.isfile(flagfile):
|
||||
abort(404, message='not found')
|
||||
return {
|
||||
'message': 'found'
|
||||
}
|
||||
|
||||
def put(self):
|
||||
cfg = get_config()
|
||||
flagfile = cfg.get('apache_restart_flagfile', apache_restart_flagfile)
|
||||
if os.path.isfile(flagfile):
|
||||
return '', 304
|
||||
with open(flagfile, 'a'):
|
||||
pass
|
||||
return {
|
||||
'message': 'success'
|
||||
}
|
||||
|
||||
|
||||
class APIIndex(Resource):
|
||||
def get(self):
|
||||
return ['infobases-available', 'infobases-all', 'publications',
|
||||
'module', 'config', 'config-test', 'apache-restart']
|
||||
|
||||
|
||||
frontend_dir = 'frontend/dist'
|
||||
app = Flask(__name__, static_url_path='/', static_folder=frontend_dir, template_folder=frontend_dir)
|
||||
api = Api(app, '/api/v1/')
|
||||
|
Loading…
Reference in New Issue
Block a user