root_path运用python_Python app.root_path方法代碼示例

本文整理匯總了Python中app.app.root_path方法的典型用法代碼示例。如果您正苦於以下問題:Python app.root_path方法的具體用法?Python app.root_path怎麽用?Python app.root_path使用的例子?那麽恭喜您, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在模塊app.app的用法示例。在下文中一共展示了a...
摘要由CSDN通过智能技术生成

本文整理匯總了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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值