本文整理匯總了Python中users.Users.as_view方法的典型用法代碼示例。如果您正苦於以下問題:Python Users.as_view方法的具體用法?Python Users.as_view怎麽用?Python Users.as_view使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類users.Users
的用法示例。
在下文中一共展示了Users.as_view方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: page_not_found
# 需要導入模塊: from users import Users [as 別名]
# 或者: from users.Users import as_view [as 別名]
from docs import Docs
# configuration
DATABASE = 'test.json'
app = flask.Flask(__name__)
app.secret_key = settings.secret_key
#URL rules: add as needed for the various dynamic pages
app.add_url_rule('/', view_func=Main.as_view('main'), methods=('get','post'))
app.add_url_rule('/<page>/', view_func=Main.as_view('main'), methods=('get','post'))
app.add_url_rule('/login/', view_func=Login.as_view('login'), methods=('get','post'))
app.add_url_rule('/remote/', view_func=Remote.as_view('remote'), methods=('get','post'))
app.add_url_rule('/music/', view_func=Music.as_view('music'), methods=('get', 'post'))
app.add_url_rule('/events/', view_func=Events.as_view('events'), methods=('get','post'))
app.add_url_rule('/users/', view_func=Users.as_view('users'), methods=('get','post'))
app.add_url_rule('/docs/', view_func=Docs.as_view('docs'), methods=('get','post'))
#error handling wrapper
@app.errorhandler(404)
def page_not_found(error):
return flask.render_template('404.html'), 404
#database handling wrappers
@app.before_request
def before_request():
"""Make sure we are connected to the database each request."""
try:
db = open(DATABASE).read()
except IOError:
db = '{"users":[],"entries":[]}'
示例2:
# 需要導入模塊: from users import Users [as 別名]
# 或者: from users.Users import as_view [as 別名]
app = flask.Flask(__name__)
# Config Mongo
mongo = db.establish_mongo_connection(app)
app.mongo = mongo
# Config secret key
app.secret_key = settings.secret_key
# Routes
app.add_url_rule('/adminnew',
view_func=Admin.as_view('admin'),
methods=["GET", "POST"])
app.add_url_rule('/adminnew/users',
view_func=Users.as_view('users'),
methods=["GET", "POST"])
app.add_url_rule('/adminnew/transactions',
view_func=UserTransactions.as_view('transactions'),
methods=["GET"])
app.add_url_rule('/adminnew/cronjobs',
view_func=Cronjobs.as_view('cronjobs'),
methods=["GET"])
app.add_url_rule('/adminnew/emails',
view_func=Emails.as_view('emails'),
methods=["GET"])
app.add_url_rule('/adminnew/unsubscribes',
view_func=Unsubscribes.as_view('unsubscribes'),
methods=["GET"])