本文整理匯總了Python中app.app.root_path方法的典型用法代碼示例。如果您正苦於以下問題:Python app.root_path方法的具體用法?Python app.root_path怎麽用?Python app.root_path使用的例子?那麽恭喜您, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在模塊app.app的用法示例。
在下文中一共展示了app.root_path方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Python代碼示例。
示例1: validate
點讚 4
# 需要導入模塊: from app import app [as 別名]
# 或者: from app.app import root_path [as 別名]
def validate(self):
if not Form.validate(self):
return False
if self.uploadfile.name not in request.files:
self.uploadfile.errors.append("Please select a valid file.")
return False
self.file_ = request.files[self.uploadfile.name]
self.filename = secure_filename(self.file_.filename)
uploads = os.listdir(os.path.join(app.root_path, app.config['UPLOAD_FOLDER']))
if self.filename in uploads:
self.uploadfile.errors.append("A file with this name already exists.")
return False
if not self.filename:
self.uploadfile.errors.append("Invalid file name.")
return False
return True
開發者ID:lasa,項目名稱:website,代碼行數:20,
示例2: get_uploads
點讚 3
# 需要導入模塊: from app import app [as 別名]
# 或者: from app.app import root_path [as 別名]
def get_uploads():
"""gets the images and other files from the uploads directory
and returns two lists of tuples in the form (name, path)
"""
images = [('none', '')]
others = [('none', '')]
uploads = os.listdir(os.path.join(app.root_path, app.config['UPLOAD_FOLDER']))
uploads.remove(".gitignore")
# sort by time last modified
uploads.sort(key=l