• <small id='JaQrk'></small><noframes id='JaQrk'>

    <i id='JaQrk'><tr id='JaQrk'><dt id='JaQrk'><q id='JaQrk'><span id='JaQrk'><b id='JaQrk'><form id='JaQrk'><ins id='JaQrk'></ins><ul id='JaQrk'></ul><sub id='JaQrk'></sub></form><legend id='JaQrk'></legend><bdo id='JaQrk'><pre id='JaQrk'><center id='JaQrk'></center></pre></bdo></b><th id='JaQrk'></th></span></q></dt></tr></i><div id='JaQrk'><tfoot id='JaQrk'></tfoot><dl id='JaQrk'><fieldset id='JaQrk'></fieldset></dl></div>

        • <bdo id='JaQrk'></bdo><ul id='JaQrk'></ul>
        <legend id='JaQrk'><style id='JaQrk'><dir id='JaQrk'><q id='JaQrk'></q></dir></style></legend>

        <tfoot id='JaQrk'></tfoot>
      1. Python Web 开发 - 有或没有框架

        Python web development - with or without a framework(Python Web 开发 - 有或没有框架)
        <tfoot id='yUanD'></tfoot>
        • <small id='yUanD'></small><noframes id='yUanD'>

              <i id='yUanD'><tr id='yUanD'><dt id='yUanD'><q id='yUanD'><span id='yUanD'><b id='yUanD'><form id='yUanD'><ins id='yUanD'></ins><ul id='yUanD'></ul><sub id='yUanD'></sub></form><legend id='yUanD'></legend><bdo id='yUanD'><pre id='yUanD'><center id='yUanD'></center></pre></bdo></b><th id='yUanD'></th></span></q></dt></tr></i><div id='yUanD'><tfoot id='yUanD'></tfoot><dl id='yUanD'><fieldset id='yUanD'></fieldset></dl></div>

            1. <legend id='yUanD'><style id='yUanD'><dir id='yUanD'><q id='yUanD'></q></dir></style></legend>

                  <tbody id='yUanD'></tbody>

                  <bdo id='yUanD'></bdo><ul id='yUanD'></ul>
                  本文介绍了Python Web 开发 - 有或没有框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我计划将 PHP 应用程序移植到 Python.该应用程序主要是关于数据收集和处理.主应用程序作为独立的命令行应用程序运行.该应用程序有一个 Web 界面,基本上是一个非常轻量级的报告界面.

                  I am planning on porting a PHP application over to Python. The application is mostly about data collection and processing. The main application runs as a stand alone command line application. There is a web interface to the application which is basically a very light weight reporting interface.

                  我没有在 PHP 版本中使用框架,但作为 Python 新手,我想知道使用 Django 或至少 Genshi 之类的东西是否有利.需要注意的是,我不希望我的应用程序分发被我需要与应用程序一起分发的框架部分所淹没.

                  I did not use a framework in the PHP version, but being new to Python, I am wondering if it would be advantageous to use something like Django or at the very least Genshi. The caveat is I do not want my application distribution to be overwhelmed by the framework parts I would need to distribute with the application.

                  在这种情况下,仅使用 Python 中的 cgi 导入是最好的方法吗?我倾向于认为框架开销太大,但也许我并没有以非常python"的方式思考它们.在这种情况下您有什么建议?

                  Is using only the cgi import in Python the best way to go in this circumstance? I would tend to think a framework is too much overhead, but perhaps I'm not thinking in a very "python" way about them. What suggestions do you have in this scenario?

                  推荐答案

                  命令行 Python,IMO,绝对是第一位的.让它发挥作用,因为这是您所做工作的核心.

                  The command-line Python, IMO, definitely comes first. Get that to work, since that's the core of what you're doing.

                  问题在于,从命令行应用程序中使用 Web 框架的 ORM 并不明显.Django 提供了从命令行应用程序使用 ORM 的具体说明.起初这些很烦人,但我认为从长远来看它们是救生员.我大量使用它来上传大量客户提供的文件.

                  The issue is that using a web framework's ORM from a command line application isn't obvious. Django provides specific instructions for using their ORM from a command-line app. Those are annoying at first, but I think they're a life-saver in the long run. I use it heavily for giant uploads of customer-supplied files.

                  不要使用纯 CGI.这不是不可能的,但是太多的事情可能会出错,而且它们都已经被框架解决了.为什么要重新发明一些东西?用别人的代码就好了.

                  Don't use bare CGI. It's not impossible, but too many things can go wrong, and they've all been solved by the frameworks. Why reinvent something? Just use someone else's code.

                  框架涉及学习,但没有真正的开销".他们并不慢.它们是您不必编写或调试的代码.

                  Frameworks involve learning, but no real "overhead". They're not slow. They're code you don't have to write or debug.

                  1. 学习一些 Python.

                  1. Learn some Python.

                  学习 Django 教程.

                  开始构建网络应用.

                  一个.启动一个 Django 项目.在该项目中构建一个小型应用程序.

                  a. Start a Django project. Build a small application in that project.

                  b.使用 Django ORM 构建新模型.为模型创建一个 Django 单元测试.确保它有效.您将能够使用默认的管理页面并进行大量操作.只是不要构建整个网站.

                  b. Build your new model using the Django ORM. Create a Django unit test for the model. Be sure that it works. You'll be able to use the default admin pages and do a lot of playing around. Just don't build the entire web site yet.

                  让您的命令行应用程序使用 Django ORM 工作.本质上,您必须对设置文件进行微调才能使该应用程序正常工作.请参阅 settings/configuration 部分.

                  Get your command-line app to work using Django ORM. Essentially, you have to finesse the settings file for this app to work nicely. See the settings/configuration section.

                  一旦你的命令行和默认管理员运行,你就可以完成网络应用程序.

                  Once you've got your command line and the default admin running, you can finish the web app.

                  这是框架的黄金法则:这是您不必编写、调试或维护的代码.使用它们.

                  Here's the golden rule of frameworks: It's code you don't have to write, debug or maintain. Use them.

                  这篇关于Python Web 开发 - 有或没有框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  env: python: No such file or directory(env: python: 没有这样的文件或目录)
                  How to evaluate environment variables into a string in Python?(如何在 Python 中将环境变量评估为字符串?)
                  Python - temporarily modify the current process#39;s environment(Python - 临时修改当前进程的环境)
                  Change current process environment#39;s LD_LIBRARY_PATH(更改当前进程环境的 LD_LIBRARY_PATH)
                  Reading and writing environment variables in Python?(在 Python 中读写环境变量?)
                  When to use sys.path.append and when modifying %PYTHONPATH% is enough(何时使用 sys.path.append 以及何时修改 %PYTHONPATH% 就足够了)
                  <tfoot id='HzFab'></tfoot>
                      <bdo id='HzFab'></bdo><ul id='HzFab'></ul>

                          <tbody id='HzFab'></tbody>

                        • <small id='HzFab'></small><noframes id='HzFab'>

                          <legend id='HzFab'><style id='HzFab'><dir id='HzFab'><q id='HzFab'></q></dir></style></legend>
                          1. <i id='HzFab'><tr id='HzFab'><dt id='HzFab'><q id='HzFab'><span id='HzFab'><b id='HzFab'><form id='HzFab'><ins id='HzFab'></ins><ul id='HzFab'></ul><sub id='HzFab'></sub></form><legend id='HzFab'></legend><bdo id='HzFab'><pre id='HzFab'><center id='HzFab'></center></pre></bdo></b><th id='HzFab'></th></span></q></dt></tr></i><div id='HzFab'><tfoot id='HzFab'></tfoot><dl id='HzFab'><fieldset id='HzFab'></fieldset></dl></div>