当前位置: 首页>>代码示例>>Python>>正文


Python Main.as_view方法代码示例

本文整理汇总了Python中main.Main.as_view方法的典型用法代码示例。如果您正苦于以下问题:Python Main.as_view方法的具体用法?Python Main.as_view怎么用?Python Main.as_view使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在main.Main的用法示例。


在下文中一共展示了Main.as_view方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: route_app

# 需要导入模块: from main import Main [as 别名]
# 或者: from main.Main import as_view [as 别名]
def route_app(app):
    app.add_url_rule('/',
                     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('/logout',
                     view_func=Logout.as_view('logout'))
    return app
开发者ID:solutionspecialist,项目名称:evelope,代码行数:12,代码来源:app.py

示例2: Flask

# 需要导入模块: from main import Main [as 别名]
# 或者: from main.Main import as_view [as 别名]
import os
from flask import Flask
from main import Main


app = Flask(__name__)


app.add_url_rule('/',
                 view_func=Main.as_view('main'),
                 methods=["GET"])


app.debug = True

# TAKE OUT FOR DEPLOYMENT
# app.run()
开发者ID:jingniwei,项目名称:my_site,代码行数:19,代码来源:app.py

示例3:

# 需要导入模块: from main import Main [as 别名]
# 或者: from main.Main import as_view [as 别名]
import flask
import settings

from main import Main
from login import Login
from remote import Remote
from music import Music

app =flask.Flask(__name__)

app.secret_key = settings.secret_key

#Routes

app.add_url_rule('/',
			view_func=Main.as_view('main'),
			methods=['GET'])

app.add_url_rule('/<page>/',
			view_func=Main.as_view('page'),
			methods=['GET'])

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'])
开发者ID:richardqlin,项目名称:flask_demo,代码行数:33,代码来源:app.py

示例4: page_not_found

# 需要导入模块: from main import Main [as 别名]
# 或者: from main.Main import as_view [as 别名]
import flask
import settings

#Views
from main import Main
from login import Login
from remote import Remote
from music import Music

app = flask.Flask(__name__)
app.secret_key = settings.secret_key

#Routes
app.add_url_rule('/', view_func=Main.as_view('main'), methods=["GET"])
app.add_url_rule('/<page>/', view_func=Main.as_view('main'), methods=["GET"])
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"])

@app.errorhandler(404)
def page_not_found(error):
	return flask.render_template('404.html'), 404

app.debug = True
app.run()
开发者ID:ovasylev,项目名称:dev-sprint3,代码行数:27,代码来源:app.py

示例5: page_not_found

# 需要导入模块: from main import Main [as 别名]
# 或者: from main.Main import as_view [as 别名]
from main import Main
from login import Login
from remote import Remote
from music import Music
from events import Events
from users import Users
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
开发者ID:zkastl,项目名称:knights3,代码行数:33,代码来源:app.py

示例6: favicon

# 需要导入模块: from main import Main [as 别名]
# 或者: from main.Main import as_view [as 别名]
app.config["SECRET_KEY"] = "T\x9cs;\x8b\[email protected]\xac\xbb\xc9m\xeb\xe8\x1f\x85]\xd2M\xf5\xae$I\x9a"

### marker for flask app generator - keep this line

# ----------------------------------------
# controllers
# ----------------------------------------

# @app.route('/favicon.ico')
# def favicon():
# 	return send_from_directory(os.path.join(app.root_path, 'static'), 'ico/favicon.ico')

# Routes
# Static main view
# Static main view
app.add_url_rule("/", view_func=Main.as_view("main"), methods=["GET"])
# Dynamic URL rule
app.add_url_rule("/login/", view_func=Login.as_view("login"), methods=["GET", "POST"])
app.add_url_rule("/plans/", view_func=Plans.as_view("plans"), methods=["GET", "POST"])
app.add_url_rule("/about/", view_func=About.as_view("about"), methods=["GET", "POST"])

# @app.errorhandler(404)
# def page_not_found(e):
# 	return render_template('404.html'), 404

# @app.route("/")
# def index():
# 	return render_template('index.html')

# @app.route("/about")
# def about():
开发者ID:joytafty,项目名称:myflask,代码行数:33,代码来源:app.py

示例7:

# 需要导入模块: from main import Main [as 别名]
# 或者: from main.Main import as_view [as 别名]
from display_videos import vidDisplay
from contact import Contact
from donate import Sponsors
from members import Members, init_db_members
from home import Home
from events import Event, init_db_events

app = flask.Flask(__name__)
app.secret_key = settings.secret_key

# Routes
app.add_url_rule('/',
                 view_func=Home.as_view('home'),
                 methods=["GET", "POST"])
app.add_url_rule('/<page>/',
                 view_func=Main.as_view('page'),
                 methods=["GET"])
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('/add/',
                 view_func=Feed.as_view('add_entry'),
                 methods=["GET", "POST"])
app.add_url_rule('/pictures/',
                 view_func=Pictures.as_view('pictures'),
                 methods=["GET", "POST"])
app.add_url_rule('/display_pictures/',
                 view_func=Display.as_view('display_pictures'),
开发者ID:Wiersma,项目名称:parts,代码行数:33,代码来源:app.py


注:本文中的main.Main.as_view方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。