如何在不依赖框架的情况下使用 python 进行 Web 开发? [英] How do I use python for web development without relying on a framework?

查看:63
本文介绍了如何在不依赖框架的情况下使用 python 进行 Web 开发?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道各种框架都有其优点,但我个人希望我在 Python 中的 Web 开发尽可能直接:少写框架,多写 python.

I know the various frameworks have their benefits, but I personally want my web development in python to be as straight-forward as possible: less writing to the framework, more writing python.

到目前为止,我发现的唯一能让我以最明显的方式做到这一点的是 web.py但我对其性能略有担忧.

The only thing I have found so far that lets me do this in the most obvious way possible is web.py but I have slight concerns on its performance.

对于那些使用 nginx(或其他风格)+mod_wsgi+web.py 的人...性能如何?可以进一步改进吗?

For those of you using nginx(or another flavour)+mod_wsgi+web.py... how's performance? Can it be improved further?

对于那些使用过 web.py、喜欢这个想法并继续写出更好的东西或找到更好的东西的人……介意指出我的来源吗?

For those of you who have used web.py, liked the idea and went on to write something better or found something better... care to point me to the source?

我想听听所有引人注目、最小但功能强大的方法.

I'd like to hear about all the conspicuous, minimal yet powerful approaches.

推荐答案

有趣的是,即使提出了一个询问如何在没有框架的情况下编写的问题,每个人仍然蜂拥而至地推广他们最喜欢的框架.OP 抱怨不想要一个重量级框架",并且回复提到了 Twisted,所有事情?!来吧,真的.

It's hilarious how, even prompted with a question asking how to write without a framework, everyone still piles in to promote their favourite framework. The OP whinges about not wanting a "heavyweight framework", and the replies mention Twisted, of all things?! Come now, really.

是的,完全有可能编写直接的 WSGI 应用程序,并从独立模块中获取所需的功能,而不是将您的代码适应一个特定框架的世界观.

Yes, it is perfectly possible to write straight WSGI apps, and grab bits of wanted functionality from standalone modules, instead of fitting your code into one particular framework's view of the world.

要走这条路,您通常需要熟悉 HTTP 和 CGI​​ 的基础知识(因为 WSGI 从早期规范中继承了很多东西).这不一定是推荐给初学者的方法,但它非常可行.

To take this route you'll generally want to be familiar with the basics of HTTP and CGI (since WSGI inherits an awful lot from that earlier specification). It's not necessarily an approach to recommend to beginners, but it's quite doable.

我想听听所有引人注目、最小但功能强大的方法

I'd like to hear about all the conspicuous, minimal yet powerful approaches

您不会听说他们,因为没有人有兴趣将自己动手"作为一种方法来推广.我,我使用了一个特定的独立模板包、一个特定的独立表单读取包、一个特定的数据访问层和一些自制的实用程序模块.我不是在写一种我可以传教的特定哲学,它们都只是无聊的工具,可以换掉,用其他同样好的东西代替.

You won't hear about them, because no-one has a tribal interest in promoting "do it yourself" as a methodology. Me, I use a particular standalone templating package, a particular standalone form-reading package, a particular data access layer, and a few home-brew utility modules. I'm not writing to one particular philosophy I can proselytise about, they're all just boring tools that could be swapped out and replaced with something else just as good.

这篇关于如何在不依赖框架的情况下使用 python 进行 Web 开发?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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