本文整理汇总了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()