Commit 733fec99 authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Configurable api basepath.

parent 32fa7a25
...@@ -6,10 +6,12 @@ from flask_cors import CORS ...@@ -6,10 +6,12 @@ from flask_cors import CORS
import logging import logging
from elasticsearch.exceptions import NotFoundError from elasticsearch.exceptions import NotFoundError
from nomad import users, files, search from nomad import users, files, search, config
from nomad.processing import UploadProc from nomad.processing import UploadProc
from nomad.utils import get_logger from nomad.utils import get_logger
base_path = config.services.api_base_path
app = Flask(__name__, static_url_path='/docs', static_folder='../docs/.build/html') app = Flask(__name__, static_url_path='/docs', static_folder='../docs/.build/html')
CORS(app) CORS(app)
api = Api(app) api = Api(app)
...@@ -129,7 +131,7 @@ class RepoCalcs(Resource): ...@@ -129,7 +131,7 @@ class RepoCalcs(Resource):
} }
@app.route('/archive/<string:upload_hash>/<string:calc_hash>', methods=['GET']) @app.route('%s/archive/<string:upload_hash>/<string:calc_hash>' % base_path, methods=['GET'])
def get_calc(upload_hash, calc_hash): def get_calc(upload_hash, calc_hash):
archive_id = '%s/%s' % (upload_hash, calc_hash) archive_id = '%s/%s' % (upload_hash, calc_hash)
logger = get_logger(__name__, archive_id=archive_id) logger = get_logger(__name__, archive_id=archive_id)
...@@ -143,10 +145,10 @@ def get_calc(upload_hash, calc_hash): ...@@ -143,10 +145,10 @@ def get_calc(upload_hash, calc_hash):
abort(500, message='Could not accessing the archive.') abort(500, message='Could not accessing the archive.')
api.add_resource(Uploads, '/uploads') api.add_resource(Uploads, '%s/uploads' % base_path)
api.add_resource(Upload, '/uploads/<string:upload_id>') api.add_resource(Upload, '%s/uploads/<string:upload_id>' % base_path)
api.add_resource(RepoCalcs, '/repo') api.add_resource(RepoCalcs, '%s/repo' % base_path)
api.add_resource(RepoCalc, '/repo/<string:upload_hash>/<string:calc_hash>') api.add_resource(RepoCalc, '%s/repo/<string:upload_hash>/<string:calc_hash>' % base_path)
if __name__ == '__main__': if __name__ == '__main__':
......
...@@ -42,6 +42,9 @@ MongoConfig = namedtuple('MongoConfig', ['host', 'users_db']) ...@@ -42,6 +42,9 @@ MongoConfig = namedtuple('MongoConfig', ['host', 'users_db'])
LogstashConfig = namedtuple('LogstashConfig', ['enabled', 'host', 'tcp_port']) LogstashConfig = namedtuple('LogstashConfig', ['enabled', 'host', 'tcp_port'])
""" Used to configure and enable/disable the ELK based centralized logging. """ """ Used to configure and enable/disable the ELK based centralized logging. """
NomadServicesConfig = namedtupe('NomadServicesConfig', ['api_base_path'])
""" Used to configure nomad services: worker, handler, api """
files = FilesConfig( files = FilesConfig(
uploads_bucket='uploads', uploads_bucket='uploads',
repository_bucket='repository', repository_bucket='repository',
...@@ -86,3 +89,6 @@ logstash = LogstashConfig( ...@@ -86,3 +89,6 @@ logstash = LogstashConfig(
host=os.environ.get('NOMAD_LOGSTASH_HOST', 'localhost'), host=os.environ.get('NOMAD_LOGSTASH_HOST', 'localhost'),
tcp_port=int(os.environ.get('NOMAD_LOGSTASH_TCPPORT', '5000')) tcp_port=int(os.environ.get('NOMAD_LOGSTASH_TCPPORT', '5000'))
) )
services = NomadServicesConfig(
api_base_path='/nomadxt/api'
)
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment