def initialize_app(flask_app): logger.info("Configuring api server") blueprint = Blueprint("api", __name__, url_prefix="/api/v1") api.init_app(blueprint) api.add_namespace(kanban_namespace) api.add_namespace(issues_namespace) flask_app.register_blueprint(blueprint)
def create_app(config_filename=None): app = Flask(__name__) blueprint = Blueprint('api', __name__) api.init_app(blueprint) api.add_namespace(login, '/login') app.register_blueprint(blueprint) cors = CORS(app, resources={r"/*": {"origins": "*"}}) return app
def init_app(app): from resources import home app.register_blueprint(home.home_blueprint) from resources import ping api.add_namespace(ping.ping_ns) from resources import traceroute api.add_namespace(traceroute.traceroute_ns)
def create_app(): app.config['SQLALCHEMY_DATABASE_URI'] = database_uri app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False app.config.SWAGGER_UI_JSONEDITOR = True app.config.update(mail_settings) db.init_app(app) mail.init_app(app) # with app.app_context(): # db.create_all() blueprint = Blueprint('api', __name__, url_prefix='/doc') api.init_app(blueprint) api.add_namespace(books_ns) api.add_namespace(borrowers_ns) api.add_namespace(loans_ns) api.add_namespace(lists_ns) app.register_blueprint(blueprint) @app.route('/') def hello_world(): return 'Hello Rasengan' # init BackgroundScheduler job scheduler = BackgroundScheduler() scheduler.add_job(reminder_job, trigger='interval', days=1) scheduler.start() try: return app except: scheduler.shutdown()
def initialize_app(flask_app): """ Initialize the application API. :param Flask flask_app: The Flask application to configure. """ # Create a blueprint to house the API, swagger can be reached from /api # and each of the models from /api/[model] blueprint = Blueprint('api', __name__, url_prefix='/api') api.init_app(blueprint) # Configure namespaces per model on the API. api.add_namespace(noms_namespace) flask_app.register_blueprint(blueprint) db.init_app(flask_app) with flask_app.app_context(): db.create_all()
def initialize_app(app): initialize_db = configure_app(app) api.add_namespace(cloud_accounts_ns) api.add_namespace(cloud_providers_ns) api.add_namespace(customers_ns) api.add_namespace(users_ns) api.init_app(app) db.init_app(app) jwt = JWTManager(app) if initialize_db: reset_database(app)
def register_namespaces() -> None: api.add_namespace(customer_api) api.add_namespace(setting_api) api.add_namespace(meeting_api) api.add_namespace(price_api) api.add_namespace(room_api) api.add_namespace(seat_api) api.add_namespace(ticket_api) api.add_namespace(administrator_api)
from api import application, api from pages import static_pages from api.dev.views import dev_ns from api.supervisor_ayi.views import supervisor_ayi_ns from api.garbage_classifier.service import load_model api.add_namespace(dev_ns, "/api/v1/dev") api.add_namespace(supervisor_ayi_ns, "/api/v1/ayi") application.register_blueprint(static_pages) api.init_app(application) load_model() if __name__ == "__main__": application.run(host="0.0.0.0", port=40086, threaded=True, debug=application.config['DEBUG'])
# only for development purposes fix client and backend to be on same port TODO @api.route('/hello') class HelloWorld(Resource): def get(self): return {'hello': 'world'} @app.route('/') def index(): # return render_template('index.html') return send_from_directory(app.static_folder, 'index.html') def initialize(): if not path.exists('data/db.feather'): db = pd.DataFrame(columns=['name', 'file']) feather.write_dataframe(db, 'data/db.feather') if __name__ == '__main__': blueprint = Blueprint('api', __name__, url_prefix='/api') api.init_app(blueprint) api.add_namespace(read) api.add_namespace(todo) api.add_namespace(pandasapi) app.register_blueprint(blueprint) initialize() app.run(debug=True)
from flask import Flask from train_model import get_model cls, model_info = get_model() from api import api, ns, api_blueprint from app import routes flask_app = Flask(__name__) api.init_app(api_blueprint) api.add_namespace(ns) flask_app.register_blueprint(api_blueprint)
def initialize_app(flask_app): configure_app(flask_app) blueprint = Blueprint('api', __name__, url_prefix='/api') api.init_app(blueprint) api.add_namespace(todo_post_namespace) flask_app.register_blueprint(blueprint)
application = Flask(__name__) # Be friendly for user to avoid tailling "/" issue application.url_map.strict_slashes = False @application.route("/") def readme(): """Provide readme on landing page help others to use""" return Response(markdown2.markdown(open("README.md", 'r').read()), mimetype='text/html') blueprint = Blueprint('LEFT', __name__) api.init_app(blueprint) api.add_namespace(hashtags_namespace) api.add_namespace(users_namespace) application.register_blueprint(blueprint) if __name__ == '__main__': port = int(sys.argv[1]) if len(sys.argv) > 1 else 8080 print("Listen Everything From Tweets (LEFT) on {}".format(port)) # Shutdown API for unit test @application.route('/shutdown') def shutdown(): func = request.environ.get('werkzeug.server.shutdown') if func is None: raise RuntimeError('Not running with the Werkzeug Server') func()