Add example of third party API
This commit is contained in:
0
app/third_party/__init__.py
vendored
Normal file
0
app/third_party/__init__.py
vendored
Normal file
14
app/third_party/app/__init__.py
vendored
Normal file
14
app/third_party/app/__init__.py
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
def create_bp(env=None):
|
||||
from flask import Blueprint, jsonify
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
from flask_restplus import Api, Resource, Namespace
|
||||
|
||||
bp = Blueprint('Example third party API', __name__)
|
||||
api = Api(bp, title='Flaskerific API', version='0.1.0')
|
||||
ns = Namespace('Third party hello world API')
|
||||
@ns.route('/')
|
||||
class ExampleResource(Resource):
|
||||
def get(self):
|
||||
return "I'm a third party API!"
|
||||
api.add_namespace(ns, path='/hello_world')
|
||||
return bp
|
BIN
app/third_party/app/app-test.db
vendored
Normal file
BIN
app/third_party/app/app-test.db
vendored
Normal file
Binary file not shown.
44
app/third_party/app/config.py
vendored
Normal file
44
app/third_party/app/config.py
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
import os
|
||||
from typing import List, Type
|
||||
|
||||
basedir = os.path.abspath(os.path.dirname(__file__))
|
||||
|
||||
|
||||
class BaseConfig:
|
||||
CONFIG_NAME = 'base'
|
||||
USE_MOCK_EQUIVALENCY = False
|
||||
DEBUG = False
|
||||
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
||||
|
||||
|
||||
class DevelopmentConfig(BaseConfig):
|
||||
CONFIG_NAME = 'dev'
|
||||
SECRET_KEY = os.getenv(
|
||||
"DEV_SECRET_KEY", "You can't see California without Marlon Widgeto's eyes")
|
||||
DEBUG = True
|
||||
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
||||
TESTING = False
|
||||
SQLALCHEMY_DATABASE_URI = "sqlite:///{0}/app-dev.db".format(basedir)
|
||||
|
||||
|
||||
class TestingConfig(BaseConfig):
|
||||
CONFIG_NAME = 'test'
|
||||
SECRET_KEY = os.getenv("TEST_SECRET_KEY", "Thanos did nothing wrong")
|
||||
DEBUG = True
|
||||
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
||||
TESTING = True
|
||||
SQLALCHEMY_DATABASE_URI = "sqlite:///{0}/app-test.db".format(basedir)
|
||||
|
||||
|
||||
class ProductionConfig(BaseConfig):
|
||||
CONFIG_NAME = 'prod'
|
||||
SECRET_KEY = os.getenv("PROD_SECRET_KEY", "I'm Ron Burgundy?")
|
||||
DEBUG = False
|
||||
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
||||
TESTING = False
|
||||
SQLALCHEMY_DATABASE_URI = "sqlite:///{0}/app-prod.db".format(basedir)
|
||||
|
||||
|
||||
EXPORT_CONFIGS: List[Type[BaseConfig]] = [
|
||||
DevelopmentConfig, TestingConfig, ProductionConfig]
|
||||
config_by_name = {cfg.CONFIG_NAME: cfg for cfg in EXPORT_CONFIGS}
|
9
app/third_party/app/routes.py
vendored
Normal file
9
app/third_party/app/routes.py
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
def register_routes(api, app, root='api'):
|
||||
from app.widget import register_routes as attach_widget
|
||||
from app.fizz import register_routes as attach_fizz
|
||||
from app.other_api import register_routes as attach_other_api
|
||||
|
||||
# Add routes
|
||||
attach_widget(api, app)
|
||||
attach_fizz(api, app)
|
||||
attach_other_api(api, app)
|
Reference in New Issue
Block a user