Commit 89b0d210 authored by Alexander Lercher's avatar Alexander Lercher

Final Fix?

parent 13dd065e
......@@ -2,8 +2,7 @@ FROM python:3
LABEL maintainer="Manuel Herold"
RUN apt-get update
RUN pip install flask
RUN pip install connexion[swagger-ui]
RUN pip install -U pip
EXPOSE 5000
......@@ -12,9 +11,8 @@ WORKDIR /app
COPY src/data-hub/reputation-calculation-microservice/app/requirements.txt /app/
RUN pip install -r requirements.txt
COPY src/data-hub/reputation-calculation-microservice/app/ /app/
COPY src/modules/ /app/
COPY src/data-hub/reputation-calculation-microservice/app/ /app/
RUN chmod a+x main.py
CMD ["python", "./main.py"]
\ No newline at end of file
......@@ -16,7 +16,8 @@ LOGGER = logging.getLogger(__name__)
#############################
import connexion
from security import swagger_util
from env_info import is_running_locally, get_resources_path
from pathlib import Path
import env_info
from flask import request
from flask import redirect
......@@ -26,29 +27,27 @@ from flask_cors import CORS
app = connexion.App(__name__, specification_dir='configs/')
CORS(app.app)
@app.app.before_request
def before_request():
if request.url.startswith('http://'):
url = request.url.replace('http://', 'https://', 1)
code = 301
return redirect(url, code=code)
@app.route('/', methods=['GET'])
def api_root():
return redirect('/api/ui')
# SSL configuration
certificate_path = get_resources_path()
context = (os.path.normpath(f'{certificate_path}/articonf1.crt'), os.path.normpath(f'{certificate_path}/articonf1.key')) # certificate and key files
if not env_info.is_running_locally():
swagger_path = "configs/swagger.yml"
# SSL configuration
certificate_path = env_info.get_resources_path()
context = (os.path.normpath(f'{certificate_path}/articonf1.crt'), os.path.normpath(f'{certificate_path}/articonf1.key')) # certificate and key files
if is_running_locally():
print("Running locally...")
app.add_api(swagger_util.get_bundled_specs(Path("configs/swagger_local.yml")),
resolver = connexion.RestyResolver("cms_rest_api"))
else:
app.add_api(swagger_util.get_bundled_specs(Path("configs/swagger.yml")),
print("Running locally...")
swagger_path = "configs/swagger_local.yml"
context = None
app.add_api(swagger_util.get_bundled_specs(Path(swagger_path)),
resolver = connexion.RestyResolver("cms_rest_api"))
# start app
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000, debug=True, use_reloader=False, ssl_context=context) # disable reloader so only subscribed once to rabbitmq
app.run(host='0.0.0.0', port=5000, ssl_context=context)#, debug=True)
\ No newline at end of file
Markdown is supported
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