当前位置: 首页>>代码示例>>Python>>正文


Python app.config方法代码示例

本文整理汇总了Python中server.app.config方法的典型用法代码示例。如果您正苦于以下问题:Python app.config方法的具体用法?Python app.config怎么用?Python app.config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在server.app的用法示例。


在下文中一共展示了app.config方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: filter_package

# 需要导入模块: from server import app [as 别名]
# 或者: from server.app import config [as 别名]
def filter_package(self, input_stack, ref_stacks):
        '''Function applies Jaccard Similarity at Package Name only'''
        input_set = set(list(input_stack.keys()))
        jaccard_threshold = float(app.config['JACCARD_THRESHOLD'])
        filetered_ref_stacks = []
        original_score = 0.0
        for ref_stack in ref_stacks:
            vcount = 0
            refstack_component_list, corresponding_version = \
                self.get_refstack_component_list(ref_stack)
            refstack_component_set = set(refstack_component_list)
            vcount = len(input_set.intersection(refstack_component_set))
            # Get similarity of input stack w.r.t reference stack
            original_score = RelativeSimilarity.compute_modified_jaccard_similarity(
                len(input_set), len(refstack_component_list), vcount)
            if original_score > jaccard_threshold:
                filetered_ref_stacks.append(ref_stack)
        return filetered_ref_stacks 
开发者ID:fabric8-analytics,项目名称:fabric8-analytics-recommender,代码行数:20,代码来源:relativesimilarity.py

示例2: move_picture_to_cloud

# 需要导入模块: from server import app [as 别名]
# 或者: from server.app import config [as 别名]
def move_picture_to_cloud(filename):
    """Uploads file to s3, deletes from server, returns url for picture."""

    folder_server = app.config['UPLOADED_PICTURES_DEST']

    client = boto3.client('s3')
    transfer = boto3.s3.transfer.S3Transfer(client)

    transfer.upload_file('{}/{}'.format(folder_server, filename),
                         app.config['S3_BUCKET'],
                         '{}/{}'.format(app.config['S3_FOLDER'], filename),
                         extra_args={'ACL': 'public-read'})

    uploaded = '{}/{}/{}'.format(client.meta.endpoint_url,
                                 app.config['S3_BUCKET'],
                                 '{}/{}'.format(app.config['S3_FOLDER'], filename))

    os.remove('{}/{}'.format(folder_server, filename))

    return uploaded 
开发者ID:elsabirch,项目名称:gallery-wall,代码行数:22,代码来源:utilities.py

示例3: setUp

# 需要导入模块: from server import app [as 别名]
# 或者: from server.app import config [as 别名]
def setUp(self):
        """To do before every test"""

        self.client = app.test_client()
        app.config['SECRET_KEY'] = '123'
        app.config['TESTING'] = True

        # connect to test database
        connect_to_db(app, "postgresql:///testdb")

        """Creates tables and adds example data to testdb"""
        db.create_all()
        example_data()

        with self.client as c:
            with c.session_transaction() as sess:
                sess['user'] = 1 
开发者ID:kjlundsgaard,项目名称:hb-final-project,代码行数:19,代码来源:tests.py

示例4: confirm_token

# 需要导入模块: from server import app [as 别名]
# 或者: from server.app import config [as 别名]
def confirm_token(self, token, expiration=3600):
        from server import app
        serializer = URLSafeTimedSerializer(app.config['SECRET_KEY'])
        session = SessionManager.Session()
        try:
            email = serializer.loads(
                token,
                salt=app.config['SECRET_PASSWORD_SALT'],
                max_age=expiration
            )
            if (email == self.email) and (not self.email_confirmed):
                self.email_confirmed = True
                user = session.query(User).filter(User.id == self.id).one()
                user.email_confirmed = True
                session.commit()
                rpc_request.send('email_changed', {'email': self.email, 'user_id': user.id})
                return json_resp({'message': 'ok'})
            else:
                raise ClientError('Invalid Token')
        except:
            raise ClientError('Invalid Token')
        finally:
            SessionManager.Session.remove() 
开发者ID:lordfriend,项目名称:Albireo,代码行数:25,代码来源:user.py

示例5: send_confirm_email

# 需要导入模块: from server import app [as 别名]
# 或者: from server.app import config [as 别名]
def send_confirm_email(self):
        """
        Send an confirm email to user. contains a link to confirm the email
        confirm link is not provide by this app, a client must implement this endpoint to complete the confirmation.
        """
        from server import app, mail
        token = self.generate_confirm_email_token()
        confirm_url = '{0}://{1}/email-confirm?token={2}'.format(app.config['SITE_PROTOCOL'],
                                                                 app.config['SITE_HOST'],
                                                                 token)
        subject = '[{0}] Email Address Confirmation'.format(app.config['SITE_NAME'])
        email_content = render_template('email-confirm.html', info={
            'confirm_title': subject,
            'confirm_url': confirm_url,
            'site_name': app.config['SITE_NAME'],
            'user_name': self.name
        })
        msg = Message(subject, recipients=[self.email], html=email_content)
        try:
            mail.send(msg)
        except SMTPAuthenticationError:
            raise ServerError('SMTP authentication failed', 500) 
开发者ID:lordfriend,项目名称:Albireo,代码行数:24,代码来源:user.py

示例6: setUp

# 需要导入模块: from server import app [as 别名]
# 或者: from server.app import config [as 别名]
def setUp(self):
        """Stuff to do before every test."""

        # Get the Flask test client
        self.client = app.test_client()

        # Create secret key to access session
        app.secret_key = "TESTINGBOBAFETCH"

        # Connect to fake database
        connect_to_db(app, 'postgresql:///bobafetchfaker')

        app.config['TESTING'] = True
    
    #############################################################################
    # API tests 
开发者ID:AnliYang,项目名称:bobafetch,代码行数:18,代码来源:tests.py

示例7: connect_to_db

# 需要导入模块: from server import app [as 别名]
# 或者: from server.app import config [as 别名]
def connect_to_db(app, db_uri=None):
    """Connect database to Flask app."""

    # app.config['SQLALCHEMY_DATABASE_URI'] = db_uri or 'postgresql:///sfparks'
    app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get("DATABASE_URL", 'postgresql:///sfparks')

    app.config['SQLALCHEMY_ECHO']=False

    # app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

    db.app = app
    db.init_app(app) 
开发者ID:cvlong,项目名称:sfparks,代码行数:14,代码来源:model.py

示例8: setUp

# 需要导入模块: from server import app [as 别名]
# 或者: from server.app import config [as 别名]
def setUp(self):
        """Stuff to do before every test."""

        # Get the Flask test client
        self.client = app.test_client()

        # Create secret key to access session
        app.secret_key = "ABC"

        # Connect to fake database
        connect_to_db(app, 'postgresql:///testdb')
        db.create_all()
        app.config['TESTING'] = True

        example_data() 
开发者ID:EmmaOnThursday,项目名称:next-book,代码行数:17,代码来源:tests.py

示例9: setUp

# 需要导入模块: from server import app [as 别名]
# 或者: from server.app import config [as 别名]
def setUp(self):
        """Before tests."""

        self.client = app.test_client()
        app.config['TESTING'] = True
        # Connect to test database
        connect_to_db(app, "postgresql:///testdb")

        # Create tables and add sample data
        db.create_all()
        example_data() 
开发者ID:Gerdie,项目名称:farm-to-front-door,代码行数:13,代码来源:tests.py

示例10: connect_to_db

# 需要导入模块: from server import app [as 别名]
# 或者: from server.app import config [as 别名]
def connect_to_db(app, database='postgresql:///shop'):
    """Connect the database to Flask app."""

    # Configure to use PostgreSQL database
    app.config['SQLALCHEMY_DATABASE_URI'] = database
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
    db.app = app
    db.init_app(app) 
开发者ID:Gerdie,项目名称:farm-to-front-door,代码行数:10,代码来源:model.py

示例11: connect_to_db

# 需要导入模块: from server import app [as 别名]
# 或者: from server.app import config [as 别名]
def connect_to_db(app):
    """Connect the database to our Flask app."""

    # Configure to use PSQL database
    app.config['SQLALCHEMY_DATABASE_URI'] = 'postgres:///coordinates'
    app.config['SQLALCHEMY_ECHO'] = True
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
    db.app = app
    db.init_app(app) 
开发者ID:sajafleming,项目名称:Sunset-Funset,代码行数:11,代码来源:model.py

示例12: connect_to_db

# 需要导入模块: from server import app [as 别名]
# 或者: from server.app import config [as 别名]
def connect_to_db(app, db_uri='postgresql:///food'):
    """Connect the database to our Flask app."""

    # created.db 'food' in virtual env, ran model.py, then created all in my model, then run seed to populate table.
    app.config['SQLALCHEMY_DATABASE_URI'] = db_uri
    db.app = app
    db.init_app(app) 
开发者ID:vivianhoang,项目名称:Fork-Spoon,代码行数:9,代码来源:model.py

示例13: setUp

# 需要导入模块: from server import app [as 别名]
# 或者: from server.app import config [as 别名]
def setUp(self):
        """Flask tests that test the routes/html pages."""
        app.config['TESTING'] = True
        app.config['SECRET_KEY'] = 'key'
        self.client = app.test_client()

        with self.client as c:
            with c.session_transaction() as sess:
                sess['user_id'] = 1234 
开发者ID:vivianhoang,项目名称:Fork-Spoon,代码行数:11,代码来源:tests.py

示例14: connect_to_db

# 需要导入模块: from server import app [as 别名]
# 或者: from server.app import config [as 别名]
def connect_to_db(app, db_uri="postgresql:///voter_data"):
    """Connect the database to our Flask app."""

    # Configure to use our PstgreSQL database
    app.config['SQLALCHEMY_DATABASE_URI'] = db_uri
    app.config['SQLALCHEMY_ECHO'] = True
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
    db.app = app
    db.init_app(app) 
开发者ID:kathryn-rowe,项目名称:Impact-Hack,代码行数:11,代码来源:model.py

示例15: connect_to_db

# 需要导入模块: from server import app [as 别名]
# 或者: from server.app import config [as 别名]
def connect_to_db(app, db_URI='postgresql:///meeting-metrics'):
    """Connect the database to our Flask app."""

    # Configure to use our PostgreSQL database
    app.config['SQLALCHEMY_DATABASE_URI'] = db_URI
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
    db.app = app
    db.init_app(app) 
开发者ID:jabrabec,项目名称:MeetingMetrics_Hackathon,代码行数:10,代码来源:model.py


注:本文中的server.app.config方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。