本文整理匯總了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
示例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
示例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
示例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()
示例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)
示例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
示例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)
示例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()
示例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()
示例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)
示例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)
示例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)
示例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
示例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)
示例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)