Web应用程序框架到底是什么? [英] What exactly is a web application framework?

查看:108
本文介绍了Web应用程序框架到底是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我进入python的cgi并遇到了Django。我不太确定我是否非常了解。是我必须在apache中安装的东西,还是可以与cgi一起使用的东西?

I'm getting into python for cgi and came across Django. I'm not quite sure I understand it very much. Is it something I have to install inside apache or is it just something I can use with my cgi?

想要知道,因为我很想学习它但是我的服务器

Wanted to know because I'd love to learn it but my server I'm using doesn't give me a lot of privileges.

谢谢

推荐答案

虽然您可以在CGI之上运行Python网络框架,但我不认为您想要:Web框架为您提供了许多额外的功能使您的编码更容易的功能,但是为此付出的代价之一是,框架具有许多额外的代码来提供该功能-每次您的Web应用程序处理时,都需要加载该代码,并执行其初始化部分

While you could run a Python web framework on top of CGI, I don't think you want to: a web framework provides you with lots of extra functionality to make your coding easier, but part of the price you pay for that is that the framework has lots of extra code to supply that functionality -- that code needs to get loaded, and its initialization parts executed, every time your web application process starts.

每次访问相应的URL,CGI都会为您的代码启动一个新的过程,并且该过程在完成对单个访问的响应后终止。因此,您确实希望尽可能少地进行初始化工作,以避免对用户请求的响应非常缓慢。

CGI starts a fresh process for your code every time the corresponding URL gets visited, and that process terminates when it's done responding to that single visit. So, you really want to do as little initialization work as possible, to avoid responding very slowly to user requests.

因此,如果您的所有托管服务提供商都允许您使用CGI,您可能希望对裸露的CGI接口进行编程,以最大程度地减少启动/关闭的开销。

So, if all your hosting provider allows you is CGI, you probably want to program "down to the bare CGI interface", in order to minimize the start-up/shut-down overhead.

您可以很好地了解Marek Kubica的方法如何在网络上使用Python中的问题和可能性。 WSGI(可以与底层Web服务器进行交互的许多其他方式)可以在CGI之上运行,因此从理论上讲,您可以使用任何支持WSGI的Python Web框架(这意味着几乎所有现代方法)-重点是,除非您只做学习和玩转,否则就不会想要一遍又一遍地招致启动开销再次在您实际服务的页面上。 (如果只是学习和玩耍,则可以在自己的计算机上运行网络服务器以供自己专用,因此托管提供商的限制是无关紧要的;-)。

You can get a good overview of the issues and possibilities in Marek Kubica's howto "HOWTO Use Python in the web". WSGI (among many other ways it can interface to the underlying web server) can run on top of CGI, so in theory you can use any Python web framework which supports WSGI (which means just about all modern ones) -- the point is, unless you're doing nothing more than just learning and "playing around", you don't want to incur that startup overhead over and over again on pages you're actually serving. (If you are just learning and playing around, you can run a web server on your own machine for your own exclusive use, so your hosting provider's limitations are irrelevant;-).

如果您决定以裸CGI级别编程,则可以从本页 -确保您遵循从该链接到有用的教程的各种链接,并到达Python CGI脚本的有用和有趣的示例的voidspace集合。

If you do decide to program at "bare CGI" level, you can start at this page -- make sure you follow the various links from it to useful tutorials and to the voidspace collection of useful and interesting examples of Python CGI scripts.

要对许多可用的Python Web应用程序框架进行调查,可以在此处开始
,其中涵盖了每个框架的位置,您将找到一些信息和链接。

For a survey of some of the many available Python web app frameworks, you can start here where for each framework covered you'll find some information and links.

最后但并非最不重要的一点,您不应忽略在< a href = http://code.google.com/appengine/ rel = nofollow noreferrer> Google App Engine -尽管有由于其自身的特性和局限性,它确实提供了符合WSGI的环境,即使是非常密集的使用也可以免费使用。有一些专门为利用App Engine而开发的有趣的轻量级框架,例如出色的 tipfy (tipfy Wiki上的此页面也链接到其他页面),但特别是,您可以在那里运行流行的django框架(如我所说,具有特殊性和局限性-尤其是其下没有关系数据库-但它仍然存在

Last but not least, you should not ignore the possibility of developing web apps on Google App Engine -- albeit with its own peculiarities and limitations, it does offer a WSGI-compliant environment that is free of charge for even pretty intense usage. There are interesting lightweight frameworks developed specifically to take advantage of App Engine, such as the excellent tipfy (this page from the tipfy wiki also links to others), but in particular you can run the popular django framework there (with peculiarities and limitations, as I said -- in particular, no relational database underneath -- but it's still the most popular choice despite that).

在App Engine成立之初,有些人担心使用它可能导致锁定-因为它与其他托管服务不同环境中,如果有人愿意的话,难道开发的Web应用程序很难移植到其他地方吗?幸运的是,像 appscale typhoonae 消除了任何此类担忧。

In App Engine's early days some people were worried that using it could lead to "lock in" -- since it's different from other hosting environments, wouldn't web apps developed for it be hard to port elsewhere if and when one wanted to? Fortunately, open-source software like appscale and typhoonae has dispelled any such worries.

这篇关于Web应用程序框架到底是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆