本文整理汇总了Python中models.Note.public方法的典型用法代码示例。如果您正苦于以下问题:Python Note.public方法的具体用法?Python Note.public怎么用?Python Note.public使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Note
的用法示例。
在下文中一共展示了Note.public方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: homepage
# 需要导入模块: from models import Note [as 别名]
# 或者: from models.Note import public [as 别名]
def homepage():
if request.method == 'POST':
if request.form.get('content'):
note = Note.create(content=request.form['content'])
rendered = render_template('note.html', note=note)
return redirect(url_for('homepage'))
return jsonify({'success': False})
notes = Note.public().limit(50)
return render_template('homepage.html', notes=notes)
示例2: homepage
# 需要导入模块: from models import Note [as 别名]
# 或者: from models.Note import public [as 别名]
def homepage():
if not session.get('logged_in'):
return redirect(url_for('login'))
if request.method == 'POST':
if request.form.get('content'):
note = Note.create(content=request.form['content'])
flash('New entry posted')
return redirect(url_for('homepage'))
notes = Note.public().paginate(get_page(), 50)
return render_template('homepage.html', notes=notes)
示例3: homepage
# 需要导入模块: from models import Note [as 别名]
# 或者: from models.Note import public [as 别名]
def homepage():
if request.method == 'POST':
if request.form.get('content'):
# New note
note = Note.create(content = request.form['content'])
# Make a note panel and jsonify
rendered = render_template('note.html', note = note)
return jsonify({'note': rendered, 'success': True})
# no content, return failure
return jsonify({'success': False})
notes = Note.public().limit(50)
return render_template('homepage.html', notes = notes)
示例4: homepage
# 需要导入模块: from models import Note [as 别名]
# 或者: from models.Note import public [as 别名]
def homepage():
if request.method == 'POST':
#create a new note in the db
if request.form.get('content'):
note = Note.create(content=request.form['content'])
# Render a single note panel and return the HTML.
rendered = render_template('note.html', note=note)
return jsonify({'note': rendered, 'success': True})
return jsonify({'success': False})
notes = Note.public().paginate(get_page(), 50)
return render_template('homepage.html', notes=notes)
示例5: homepage
# 需要导入模块: from models import Note [as 别名]
# 或者: from models.Note import public [as 别名]
def homepage():
if request.method == 'POST':
if request.form.get('content'):
# Create a new note in the db.
note = Note.create(content=request.form['content'])
# Render a single note panel and return the HTML.
rendered = render_template('note.html', note=note)
return jsonify({'note': rendered, 'success': True})
# If there's no content, indicate a failure.
return jsonify({'success': False})
notes = Note.public().limit(50)
return render_template('homepage.html', notes=notes)
示例6: homepage
# 需要导入模块: from models import Note [as 别名]
# 或者: from models.Note import public [as 别名]
def homepage():
if request.method == 'POST':
print('/ request method is post')
if request.form.get('content'):
print('/ request metho is post,content is ', request.form['content'])
note = Note.create(content=request.form['content'])
rendered = render_template('note.html', note=note)
return jsonify({'note': rendered, 'success': True})
return jsonify({'success': False})
print('/ request method is get')
notes = Note.public().paginate(get_page(), 50)
return render_template('homepage.html', notes=notes)
示例7: homepage
# 需要导入模块: from models import Note [as 别名]
# 或者: from models.Note import public [as 别名]
def homepage():
"""
Displays the list of notes and creates new ones
"""
if request.method == 'POST':
if request.form.get('content'):
# Create a new note in the db.
note = Note.create(title=request.form['title'],
content=request.form['content'],
categories=request.form['categories'])
# Render a single note panel and return the HTML.
rendered = render_template('note.html', note=note)
return jsonify({'note': rendered, 'success': True})
# If there's no content, indicate a failure.
return jsonify({'success': False})
# For now it will only show the 50 most recent notes,
# for us not to worry with pagination.
notes = Note.public().limit(50)
return render_template('homepage.html', notes=notes)
示例8: get_query
# 需要导入模块: from models import Note [as 别名]
# 或者: from models.Note import public [as 别名]
def get_query(self):
return Note.public()