def create_app(config_name='default'): app = Flask(__name__) Config.init_app(app) CORS(app, resources={r"/api/*": {"origins": "*"}}) db.init_app(app) from main import main as main_blueprint app.register_blueprint(main_blueprint) return app
def create_app(): app = Flask(__name__) Config.init_app(app) CORS(app, resources={r"/api/*": {"origin": "*"}}) db.init_app(app) from api import api as api_blueprint app.register_blueprint(api_blueprint, url_prefix="/api") return app
def create_app(config_class=Config()): # Initialize app app = Flask(__name__) app.config.from_object(Config) # Import routes from application.models import Question from application.auth.routes import auth from application.posts.routes import posts from application.main.routes import main from application.profile.routes import profile # Register blueprints app.register_blueprint(auth) app.register_blueprint(posts) app.register_blueprint(main) app.register_blueprint(profile) # Initialize plugins db.init_app(app) loginManager.init_app(app) bcrypt.init_app(app) # Add function to jinja global functions app.jinja_env.globals.update(findQuestion=findQuestion) # Create all tables with app.app_context(): db.create_all() return app
def create_app(): app = Flask(__name__) Config(app) return app
def __init__(self): self.config = Config()
data_source.frequency_of_release_other, DataSource.purpose == data_source.purpose, ).with_entities(DataSource.id).all()) print(f"Data source #{data_source.id}:") if other_identical_data_sources: for other_identical_data_source in other_identical_data_sources: print( f" Absorbed #{other_identical_data_source.id}" ) count += 1 data_source.merge(other_identical_data_sources) db.session.commit() except Exception as e: print(e) db.session.rollback() finally: db.session.close() print(f"Finished. Merged {count} duplicate data sources.") if __name__ == "__main__": app = create_app(Config()) merge_identical_duplicate_data_sources(app)
import copy import email import smtplib from email import encoders from email.mime.base import MIMEBase from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText from application.server import app from gatco.response import json, text, html from application.config import Config config = Config() import os import random import string import aiofiles import time MAIL_LIST = [{ "id": "*****@*****.**", "password": "******" }, { "id": "*****@*****.**", "password": "******" }] MAIL_LIST_TMP = [] @app.route('/api/email/send', methods=["POST", "OPTIONS"]) async def send_mail(request): global MAIL_LIST global MAIL_LIST_TMP data = request.json
def __init__(self): self.http_requests = Requester() self.logger = Logger().get_logger() self.config = Config()
import json from flask import Blueprint, Response, request from application.config import Config from application.logger import Logger from application.utils import Utils logger = Logger().get_logger() oauth = Blueprint( 'oauth', __name__, url_prefix='/api/oauth', ) CONFIG = Config() UTILS = Utils() @oauth.route('/lifecheck', methods=['GET']) @oauth.route('/lifecheck/', methods=['GET', 'POST']) def lifecheck(): app_name = CONFIG.app_name logging_json = {'app_name': app_name} logger.info(logging_json) return Response(headers=CONFIG.response_headers, response=json.dumps({ 'appName': app_name, 'stage': CONFIG.stage, 'path': 'api/oauth/lifecheck', 'status': 200 }))
def init_config(config=None, **settings): if not config: from application.config import Config return Config.load()
def init_logging(**kwargs): from application.lib.logging import initialize root_logger = logging.getLogger() root_logger.setLevel(logging.getLevelName(Config.LOG_LEVEL)) initialize(root_logger, **kwargs) def init_config(config=None, **settings): if not config: from application.config import Config return Config.load() Config.load() # init database/adapter compat.register() db = SQLAlchemy() # init models/migrations load_models() migrate = Migrate() # init celery object redis_db = make_redis() celery = make_celery() # init compress object compress = Compress()
import json # import pandas as pd # import dash_table # from dash.exceptions import PreventUpdate import plotly.graph_objects as go # import dash_daq as daq # import time import numpy as np # import time # import math # from datetime import datetime # configs configuration = Config() parser = ConfigParser() parser.read("settings.ini") state = configuration.state """ create Dash app load stylesheets """ app = Dash( __name__, # external_stylesheets=[dbc.themes.BOOTSTRAP], meta_tags=[{ "name": "viewport", "content": "width=device-width, initial-scale=1.0" }])
def __init__(self): self.http_requests = Requester() self.config = Config()