我正在学习 python,并且有兴趣使用它来编写网络脚本。有哪些框架?我需要一个吗?
我一直在学习在 ArcGIS 和其他一些非 Web 应用程序中使用 python。然而,现在我已经开始构建个人网站,我有兴趣使用它进行 Web 开发(因为它是我目前知道的唯一脚本语言)。
我注意到有很多这样的东西被称为“框架”,比如 Django。据我了解,它们只是一组软件包,可以帮助您避免重新发明轮子,但我真的不知道它们是如何工作的。
此外,我不喜欢 GUI,如果我需要一个框架,我想找到一个可以通过终端使用的框架,一开始很简单,当我准备好时可以扩展到更复杂的框架。关于框架有什么建议或想法吗?为什么我想使用框架?
I've been learning python for use in ArcGIS and some other non-web applications. However, now that I've taken on building a personal website I am interested in using it for web development (as it is the only scripting language I currently know).
I've noticed that there are a lot of these things called "frameworks", such as Django. From what I understand they are just a collection of packages to save you from re-inventing the wheel but I don't really know how they work.
Furthermore, I do not like GUIs, if I need a framework I would like to find one that could be used through a terminal, starts out simple and can be scaled for more complexity when I'm ready. Any advice or ideas on frameworks and why I would want to use one?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Python Web 框架与 GUI 无关,都可以通过终端使用。
正如您所说,框架的好处在于通过提供构建网站所需的组件来让您的生活更轻松:主要是通过 ORM、模板系统和 URL 路由进行数据库交互。最重要的是,大型框架还包括可选的附加功能,例如用户身份验证、管理界面等。
就我个人而言,我喜欢 Django,但你的情况可能会有所不同:不过,我想说的是,无论你用 Python 和 Web 做什么,都需要某种框架,即使它是绝对最小的框架之一,例如Flask 基本上只做路由部分。当这些东西已经为你完成时,从头开始编写这些东西根本没有意义。
The Python web frameworks have nothing to do with GUIs, and can all be used via the terminal.
The benefits of a framework, as you say, are all to do with making your life easier by supplying the components you need to build a website: the main ones are database interaction through an ORM, a templating system, and URL routing. On top of that, the big frameworks also included optional extras like user authentication, administration interface, and so on.
Personally I like Django, but your mileage may vary: I would say, though, that whatever you do with Python and the web will require some sort of framework, even if it's one of the absolute minimal ones like Flask which basically do just the routing part. There's simply no point in writing all this stuff from scratch when it's been done for you.
我赞同上面的帖子:Django 是一个很棒的框架,从长远来看将为您节省大量时间。
编写 Web 应用程序时遇到的几乎所有挑战都已得到解决,例如如何发送电子邮件?编辑数据的管理界面怎么样?用户安全?
在我看来,选择最好的框架完全取决于该框架周围的生态系统。它的使用情况如何?它在互联网上广泛讨论吗?其他人是否遇到并解决了我面临的问题?
至于从哪里开始,请参阅此处的 Django 教程:
http://docs.djangoproject.com/en/1.2/intro/tutorial01/
如果您认为 Django 为您提供了太多功能,我建议您看一下 CherryPy,以比较不同且简单得多的方法。
I'd second the post above: Django is a great framework and will save you loads of time in the long run.
Pretty much every challenge you'll come across when writing a web application will already have been solved, e.g. How do I send emails? What about an admin interface to edit the data? User security?
In my view picking the best framework is all about the ecosystem around that framework. How well used is it? Is it discussed widely on the internet? Have others encountered, and solved, the problems I'm facing?
In terms of where you start, see the Django Tutorial here:
http://docs.djangoproject.com/en/1.2/intro/tutorial01/
If you think Django offers you too much, I'd recommend that you take a look at CherryPy just to compare the different, and much simpler, approach.
使用Python,您有很多选择。首先,我建议您查看此处——它解释了基础知识并提供了相当完整的列表框架。
如果您正在寻找一开始简单但也可以处理更复杂的东西,那么您应该看看 web2py。它不需要安装或配置,没有依赖项,并且包含 Web 服务器和关系数据库。它还包括一个可选的基于 Web 的集成开发环境和管理界面,但如果您愿意,也可以通过终端进行工作。
它非常容易学习并且是为易于使用、更快的开发和安全性。由于包含的脚手架应用程序以及许多合理的默认行为,您可以用很少的代码完成很多工作。当事情变得更加复杂时,web2py 可以处理它,因为它是一个集成良好的全栈框架,具有许多内置功能,包括数据库抽象层、表单处理和验证、访问控制、Web 服务和简单的 Ajax一体化。
With Python, you've got lots of options. To start, I would recommend looking here -- it explains the basics and provides a fairly complete list of frameworks.
If you're looking for something that starts out simple but can also handle more complexity, then you should take a look at web2py. It requires no installation or configuration, has no dependencies, and includes a web server and a relational database. It also includes an optional web-based integrated development environment and admin interface, but you can work through the terminal instead if you prefer.
It's very easy to learn and was designed for ease of use, faster development, and security. You can get a lot done with very little code thanks to the included scaffolding app along with many sensible default behaviors. As things get more complex, web2py can handle it, as it is a well-integrated full-stack framework with lots of built-in functionality, including a database abstraction layer, form handling and validation, access control, web services, and easy Ajax integration.
就我个人而言,我不使用任何框架,我要么在 BaseHTTPServer 上从头开始编写,要么使用 WSGI(使用 mod_wsgi)。
写骨架有点长,但我认为更快(我指的是运行时),约束更少,需要学习的东西也更少。
Personnally, I don't use any framework, I write either from scratch on BaseHTTPServer, or using WSGI (with mod_wsgi).
It is a bit long to write the skeleton, but I think it is faster (I mean at runtime), there is less constraints, and there is lesser to learn.