本文整理匯總了Python中circuits.web.Server.run方法的典型用法代碼示例。如果您正苦於以下問題:Python Server.run方法的具體用法?Python Server.run怎麽用?Python Server.run使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類circuits.web.Server
的用法示例。
在下文中一共展示了Server.run方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: main
# 需要導入模塊: from circuits.web import Server [as 別名]
# 或者: from circuits.web.Server import run [as 別名]
def main():
app = Server(("0.0.0.0", 8000))
Root().register(app)
Static(docroot="static").register(app)
env = Environment(loader=FileSystemLoader("templates"))
JinjaRenderer(env, defaults).register(app)
Sessions().register(app)
# LoginManager().register(app)
app.run()
示例2: ACL
# 需要導入模塊: from circuits.web import Server [as 別名]
# 或者: from circuits.web.Server import run [as 別名]
class ACL(Component):
allowed = ["127.0.0.1"]
@handler("request", priority=1.0)
def on_request(self, event, request, response):
"""Filter Requests applying IP based Authorization
Filter any incoming requests at a higher priority than the
default dispatcher and apply IP based Authorization returning
a 403 Forbidden response if the Remote IP Address does not
match the allowed set.
"""
if not request.remote.ip in self.allowed:
event.stop()
return Forbidden(request, response)
class Root(Controller):
def index(self):
return "Hello World!"
app = Server(("0.0.0.0", 8000))
ACL().register(app)
Root().register(app)
app.run()
示例3: run
# 需要導入模塊: from circuits.web import Server [as 別名]
# 或者: from circuits.web.Server import run [as 別名]
def run():
port = os.environ.get("PORT", 8000)
app = Server(("0.0.0.0", int(port)))
Root().register(app)
app.run()