added baspath used for fuzzing and use blueprints for api routes

This commit is contained in:
Jan Friedli 2020-07-13 09:52:34 +02:00
parent e258b3084d
commit b39d16eaf8
No known key found for this signature in database
GPG key ID: F945FA2FCA30549D
2 changed files with 35 additions and 43 deletions

19
main.py
View file

@ -17,6 +17,7 @@ def create_app(test_config=None):
app.config['SWAGGER'] = {
'title': 'Mat2 Web API',
'version': '1.0.0',
'basePath': '/api'
}
# optionally load settings from config.py
app.config.from_object('config')
@ -32,25 +33,9 @@ def create_app(test_config=None):
app.register_blueprint(frontend.routes)
# Restful API hookup
api = Api(app)
app.register_blueprint(rest_api.api_bp)
Swagger(app)
CORS(app, resources={r"/api/*": {"origins": utils.get_allow_origin_header_value()}})
api.add_resource(
rest_api.APIUpload,
'/api/upload',
resource_class_kwargs={'upload_folder': app.config['UPLOAD_FOLDER']}
)
api.add_resource(
rest_api.APIDownload,
'/api/download/<string:key>/<string:secret>/<string:filename>',
resource_class_kwargs={'upload_folder': app.config['UPLOAD_FOLDER']}
)
api.add_resource(
rest_api.APIBulkDownloadCreator,
'/api/download/bulk',
resource_class_kwargs={'upload_folder': app.config['UPLOAD_FOLDER']}
)
api.add_resource(rest_api.APISupportedExtensions, '/api/extension')
return app