比 Web.py 更高效的 Web 框架?请非常Pythonic!
我喜欢 webpy,它确实非常 Pythonic,但我不喜欢必须添加 url 映射并创建一个类,通常其中只有 1 个函数。 我对快速减少代码输入和原型设计感兴趣。
对于 webpy 的爱好者来说,有没有人有任何即将推出的建议,例如 Bobo、Nagare、Bottle、Flask、Denied、cherrypy?
是什么让它成为一个很好的理由?
另外,我不介意错过(强烈)基于文本的模板系统,我使用面向对象的 HTML 生成。代码应该看起来像这样:
def addTask(task):
db.tasks.append({'task':task,'done':False})
return 'Task Added'
def listTasks():
d = doc()
d.body.Add(Ol(id='tasks'))
for task in db.tasks:
taskStatus = 'notDoneTask'
if task.done: taskStatus = 'doneTask'
d.body.tasks.Add(Li(task.task,Class=taskStatus))
return d
简约的 CherryPy 目前看起来是一个强有力的竞争者。会有其他人在最后一刻做出拯救吗?
I love webpy, it's really quite Pythonic but I don't like having to add the url mappings and create a class, typically with just 1 function inside it.
I'm interested in minimising code typing and prototyping fast.
Does anyone have any up and coming suggestions such as Bobo, Nagare, Bottle, Flask, Denied, cherrypy for a lover of webpy's good things?
What makes it a good reason?
Also I don't mind missing out (strongly) text based templating systems, I use object oriented HTML generation. Code should be able to look something like this:
def addTask(task):
db.tasks.append({'task':task,'done':False})
return 'Task Added'
def listTasks():
d = doc()
d.body.Add(Ol(id='tasks'))
for task in db.tasks:
taskStatus = 'notDoneTask'
if task.done: taskStatus = 'doneTask'
d.body.tasks.Add(Li(task.task,Class=taskStatus))
return d
Minimalistic CherryPy is looking like a strong contender at the moment. Will there be a last minute save by another?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Flask,Armin Ronacher 的微框架构建在 Werkzeug、Jinja2 和良好的意图之上(尽管您可以使用任何模板引擎)你喜欢,或者根本不喜欢),URL 映射非常简洁。
也许这就是您正在寻找的?
Flask, Armin Ronacher's microframework built on top of Werkzeug, Jinja2 and good intentions (though you can use whichever templating engine you like, or none at all), does URL mapping very concisely.
Maybe that's what you're looking for?
CherryPy 允许您在树中连接处理程序而不是正则表达式。 web.py 可能会这样写:
等效的 CherryPy 是:
您甚至可以在 CherryPy 中完全省去类:
CherryPy allows you to hook up handlers in a tree instead of regexes. Where web.py might write:
The equivalent CherryPy would be:
You can even dispense with classes entirely in CherryPy:
我是 webpy 的用户。最近,我发现了 django,我认为它很棒。您只需专注于业务逻辑,框架就会为您完成大部分工作。
I was a user of webpy. And lately, I have found django, and I think that it is great. You can just focus on your business logic and the framework will do most things for you.