Added Minio stuff

This commit is contained in:
Pünkösd Marcell 2020-03-25 01:57:54 +01:00
parent 453b686cbe
commit 7118af3c15
5 changed files with 17 additions and 7 deletions

View File

@ -1,3 +1,4 @@
werkzeug
requests requests
blinker blinker
Flask Flask

View File

@ -4,7 +4,7 @@ from flask import Flask
from werkzeug.middleware.proxy_fix import ProxyFix from werkzeug.middleware.proxy_fix import ProxyFix
# import stuff # import stuff
from utils import register_all_error_handlers from utils import register_all_error_handlers, storage
# import views # import views
from views import ObjectView from views import ObjectView
@ -13,9 +13,16 @@ from views import ObjectView
app = Flask(__name__) app = Flask(__name__)
app.wsgi_app = ProxyFix(app.wsgi_app, x_proto=1) app.wsgi_app = ProxyFix(app.wsgi_app, x_proto=1)
# init stuff
storage.init_app(app)
# important stuff # important stuff
app.secret_key = os.environ.get('SECRET_KEY', os.urandom(12)) app.secret_key = os.environ.get('SECRET_KEY', os.urandom(12))
app.config['MINIO_ENDPOINT'] = os.environ['MINIO_ENDPOINT']
app.config['MINIO_ACCESS_KEY'] = os.environ['MINIO_ACCESS_KEY']
app.config['MINIO_SECRET_KEY'] = os.environ['MINIO_SECRET_KEY']
# register error handlers # register error handlers
register_all_error_handlers(app) register_all_error_handlers(app)
@ -23,9 +30,6 @@ register_all_error_handlers(app)
for view in [ObjectView]: for view in [ObjectView]:
view.register(app, trailing_slash=False) view.register(app, trailing_slash=False)
# start debugging if needed
# start debuggig if needed
if __name__ == "__main__": if __name__ == "__main__":
app.run(debug=True) app.run(debug=True)

View File

@ -1,3 +1,4 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from .require_decorators import json_required from .require_decorators import json_required
from .error_handlers import register_all_error_handlers from .error_handlers import register_all_error_handlers
from .storage import storage

View File

@ -0,0 +1,3 @@
from flask_minio import Minio
storage = Minio()

View File

@ -1,6 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from flask import jsonify from flask import jsonify
from flask_classful import FlaskView from flask_classful import FlaskView
from utils import storage
class ObjectView(FlaskView): class ObjectView(FlaskView):