當前位置: 首頁>>代碼示例>>Python>>正文


Python Users.as_view方法代碼示例

本文整理匯總了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":[]}'
開發者ID:zkastl,項目名稱:knights3,代碼行數:33,代碼來源:app.py

示例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"])

開發者ID:RaghavRamesh,項目名稱:BillPin-Admin-Panel,代碼行數:31,代碼來源:adminpanel.py


注:本文中的users.Users.as_view方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。