本文整理汇总了Python中flaskext.uploads.UploadSet.url方法的典型用法代码示例。如果您正苦于以下问题:Python UploadSet.url方法的具体用法?Python UploadSet.url怎么用?Python UploadSet.url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flaskext.uploads.UploadSet
的用法示例。
在下文中一共展示了UploadSet.url方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_url_based
# 需要导入模块: from flaskext.uploads import UploadSet [as 别名]
# 或者: from flaskext.uploads.UploadSet import url [as 别名]
def test_url_based(self):
app = Flask(__name__)
app.config.update(
UPLOADED_FILES_DEST='/uploads',
UPLOADED_FILES_URL='http://localhost:5001/'
)
uset = UploadSet('files')
configure_uploads(app, uset)
with app.test_request_context():
url = uset.url('foo.txt')
assert url == 'http://localhost:5001/foo.txt'
assert '_uploads' not in app.modules
示例2: test_url_generated
# 需要导入模块: from flaskext.uploads import UploadSet [as 别名]
# 或者: from flaskext.uploads.UploadSet import url [as 别名]
def test_url_generated(self):
app = Flask(__name__)
app.config.update(
UPLOADED_FILES_DEST='/uploads'
)
uset = UploadSet('files')
configure_uploads(app, uset)
with app.test_request_context():
url = uset.url('foo.txt')
gen = url_for('_uploads.uploaded_file', setname='files',
filename='foo.txt', _external=True)
assert url == gen