From 0ea35808f3bbdde49d2f0c51b0f5a653d41ea92c Mon Sep 17 00:00:00 2001 From: Alexis Lahouze Date: Thu, 16 Jun 2016 23:03:45 +0200 Subject: [PATCH] Remove blueprint. --- accountant/__init__.py | 24 ++++++++++++++----- accountant/{api => }/fields.py | 0 accountant/{api => }/models/__init__.py | 0 accountant/{api => }/models/accounts.py | 0 accountant/{api => }/models/operations.py | 0 .../{api => }/models/scheduled_operations.py | 0 accountant/{api => }/models/users.py | 0 accountant/{api => }/views/__init__.py | 0 accountant/{api => }/views/accounts.py | 0 accountant/{api => }/views/models.py | 0 accountant/{api => }/views/operations.py | 0 accountant/{api => }/views/parsers.py | 0 .../{api => }/views/scheduled_operations.py | 0 accountant/{api => }/views/users.py | 0 14 files changed, 18 insertions(+), 6 deletions(-) rename accountant/{api => }/fields.py (100%) rename accountant/{api => }/models/__init__.py (100%) rename accountant/{api => }/models/accounts.py (100%) rename accountant/{api => }/models/operations.py (100%) rename accountant/{api => }/models/scheduled_operations.py (100%) rename accountant/{api => }/models/users.py (100%) rename accountant/{api => }/views/__init__.py (100%) rename accountant/{api => }/views/accounts.py (100%) rename accountant/{api => }/views/models.py (100%) rename accountant/{api => }/views/operations.py (100%) rename accountant/{api => }/views/parsers.py (100%) rename accountant/{api => }/views/scheduled_operations.py (100%) rename accountant/{api => }/views/users.py (100%) diff --git a/accountant/__init__.py b/accountant/__init__.py index d1487f2..94b0363 100644 --- a/accountant/__init__.py +++ b/accountant/__init__.py @@ -16,25 +16,37 @@ """ from flask import Flask, redirect, url_for -from flask.ext.sqlalchemy import SQLAlchemy +from flask_restplus import Api +from flask_cors import CORS +from flask_sqlalchemy import SQLAlchemy # The app -app = Flask(__name__, static_folder=None) +app = Flask(__name__, static_folder=None, template_folder=None) app.config.from_pyfile('config.cfg') app.config['SQLALCHEMY_ECHO'] = app.debug app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True +# Database initialization. db = SQLAlchemy(app) -# Must be after db declaration because some components in blueprints need it. -from .api import blueprint as api +# API initialization. +authorizations = { + 'apikey': { + 'type': 'apiKey', + 'in': 'header', + 'name': 'Authorization' + } +} -app.register_blueprint(api, url_prefix='/api') +api = Api(app, doc='/doc/', authorizations=authorizations) +CORS(app) +# Load all views. +from .views import * # flake8: noqa # Redirect / to API documentation. @app.route('/') def index(): - return redirect(url_for('api.doc')) + return redirect(url_for('doc')) diff --git a/accountant/api/fields.py b/accountant/fields.py similarity index 100% rename from accountant/api/fields.py rename to accountant/fields.py diff --git a/accountant/api/models/__init__.py b/accountant/models/__init__.py similarity index 100% rename from accountant/api/models/__init__.py rename to accountant/models/__init__.py diff --git a/accountant/api/models/accounts.py b/accountant/models/accounts.py similarity index 100% rename from accountant/api/models/accounts.py rename to accountant/models/accounts.py diff --git a/accountant/api/models/operations.py b/accountant/models/operations.py similarity index 100% rename from accountant/api/models/operations.py rename to accountant/models/operations.py diff --git a/accountant/api/models/scheduled_operations.py b/accountant/models/scheduled_operations.py similarity index 100% rename from accountant/api/models/scheduled_operations.py rename to accountant/models/scheduled_operations.py diff --git a/accountant/api/models/users.py b/accountant/models/users.py similarity index 100% rename from accountant/api/models/users.py rename to accountant/models/users.py diff --git a/accountant/api/views/__init__.py b/accountant/views/__init__.py similarity index 100% rename from accountant/api/views/__init__.py rename to accountant/views/__init__.py diff --git a/accountant/api/views/accounts.py b/accountant/views/accounts.py similarity index 100% rename from accountant/api/views/accounts.py rename to accountant/views/accounts.py diff --git a/accountant/api/views/models.py b/accountant/views/models.py similarity index 100% rename from accountant/api/views/models.py rename to accountant/views/models.py diff --git a/accountant/api/views/operations.py b/accountant/views/operations.py similarity index 100% rename from accountant/api/views/operations.py rename to accountant/views/operations.py diff --git a/accountant/api/views/parsers.py b/accountant/views/parsers.py similarity index 100% rename from accountant/api/views/parsers.py rename to accountant/views/parsers.py diff --git a/accountant/api/views/scheduled_operations.py b/accountant/views/scheduled_operations.py similarity index 100% rename from accountant/api/views/scheduled_operations.py rename to accountant/views/scheduled_operations.py diff --git a/accountant/api/views/users.py b/accountant/views/users.py similarity index 100% rename from accountant/api/views/users.py rename to accountant/views/users.py