本文整理汇总了Python中models.Folder.get方法的典型用法代码示例。如果您正苦于以下问题:Python Folder.get方法的具体用法?Python Folder.get怎么用?Python Folder.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Folder
的用法示例。
在下文中一共展示了Folder.get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: folder
# 需要导入模块: from models import Folder [as 别名]
# 或者: from models.Folder import get [as 别名]
def folder(folder_name):
try:
f = Folder.get(name=folder_name)
except peewee.DoesNotExist:
return jsonify(message='error'), 404
if request.method == 'POST':
file = request.files['file']
if file:
actual_filename = secure_filename(
folder_name + '_' + file.filename)
if os.path.exists(os.path.join(app.config['UPLOAD_FOLDER'], actual_filename)):
return jsonify(message='error'), 409
file.save(
os.path.join(app.config['UPLOAD_FOLDER'], actual_filename))
f2 = File.create(folder=folder_name,
filename=file.filename,
public_share_url=generate_url(),
private_share_url=generate_url(),
private_share_password=generate_password(),
open_public_share=False,
open_private_share=False)
f2.save()
return jsonify(message='OK'), 201
if request.method == 'GET':
files = File.select().where(File.folder == folder_name)
items = [{
'filename': x.filename,
'public': x.public_share_url,
'private': x.private_share_url,
'password': x.private_share_password,
'openPublic': x.open_public_share,
'openPrivate': x.open_private_share
} for x in files]
return jsonify(message='OK', items=items)
if request.method == 'DELETE':
try:
f.delete_instance()
except peewee.IntegrityError:
return jsonify(message='error'), 409
return jsonify(message='OK')
示例2: get
# 需要导入模块: from models import Folder [as 别名]
# 或者: from models.Folder import get [as 别名]
def get(self,key):
folder=Folder.get(key)
self.render('views/admin/folderedit.html', {'folder':folder,'key':key})