问题标签 [web.py]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
python - 分析 Python 生成器
我正在调整一个应用程序,该应用程序大量使用生成器来生成结果以提供 web.py Web 界面。
到目前为止,我可以将对 for 循环的调用和产生输出的语句包装在一个函数中,并使用cProfile.run()
or调用它runctx()
。从概念上讲:
在 web.py 中,我必须用以下方式包装它,因为我想在每个迭代步骤中立即从可能长时间运行的计算中生成输出yield
:
有没有办法像在第二个示例中一样使用第一个示例中的生成器的所有调用?
python - Web.py URL 映射不接受“/”
所以我见过的每个 web.py 教程都包含这一行:
然后,稍后,使用 GET 函数等定义索引类。我的问题是,这不起作用。使用上面的代码,我得到一个 404 错误。使用以下映射工作:
但这至少在一开始会捕获每一个可能的 URL,我只希望“索引”处理对域根目录的访问。哈普?
一些基本信息:
Python 2.6、web.py 0.3、带有 mod_wsgi 的 Apache 2.2
不知道还有什么有用的,所以如果我可以添加一些重要的东西(也许是来自 Apache 的 VirtualHost?)请询问,我会在这里添加它。
编辑:包括我的 Apache VirtualHost 配置:
python - 根据文件位置,同一行行为正确或给我一条错误消息
给我一个错误信息:
没有给我错误消息:
为什么?
python - Google App Engine 上的 web.py
我正在尝试让web.py
应用程序在 GAE 上运行。我希望像下面这样的东西可能会起作用
但显然该app
对象不符合run_wsgi_app
函数的预期。错误消息说 sth like app has no __call__ function
,所以我尝试通过app.run
,但这也不起作用。
我怎样才能打电话run_wsgi_app
上班?
python - 在 Apache 上部署时使用带有相对路径的 webpy 的 web.template.render()
使用 webpy,引用 web.template.render() 的模板目录的正确方法是什么,以便它在 webpy 开发 Web 服务器和 Apache 上都可以工作?
以下代码使用开发服务器工作,但在我的 Apache 服务器上运行时不起作用。
我知道问题就是web.template.render('templates/')
问题所在,因为当 Apache 从C:\Program Files\Apache Software Foundation\Apache2.2
. 我的模板目录在我的项目文件夹中。
我不想做的是使用绝对路径,因为我希望能够移动我的项目文件,而不必修改代码以使其保持工作。
json - 如何在 JSON 对象中为查询字符串形成一个数组?
在查询字符串中的 JSON 对象中发送数组时,每个数组元素是否应该具有相同的键?例如,如果我有这个 JSON 对象:
查询字符串是否应该像这样,所有键都完全相同(sodas%5B%5D
)?
或者查询字符串中是否应该有一个索引值或其他东西(sodas%5B0%5D
,sodas%5B1%5D
等)?
python - 在 Web.py 上进行身份验证 - 此代码对生产不安全吗?
我正在制作一个需要登录管理页面的简单网络应用程序。我在 web.py 网站 ( http://webpy.org/cookbook/userauth )上遇到了这个咒语:
然而,该页面也给出了一个不祥的警告:“请勿在真实站点上使用此代码 - 这仅用于说明。”。我想知道这是否有任何重大漏洞,我对网络编程有点不熟悉,所以只是想确保使用此代码不会在不知不觉中使应用程序对微不足道的攻击向量开放?
非常感谢
python - 如何通知我的桌面应用程序远程服务器上的状态更改?
我正在创建一个桌面应用程序,该应用程序在本地执行某些操作之前需要远程服务器的授权。
在服务器批准授权请求时通知我的桌面应用程序的最佳方式是什么?授权平均需要 20 秒,最少 5 秒,超时时间为 120 秒。
我考虑过每隔几秒钟左右轮询一次服务器3
,但是当我更广泛地部署应用程序时,这将很难扩展,而且看起来不优雅。
我可以完全控制服务器和客户端 API 的设计。该服务器web.py
在 Ubuntu 10.10、Python 2.6 上使用。
ajax - Building HTML with templates versus building it in javascript?
I recently started making web apps, and while I make some stuff that works, I'm not sure of the best practices.
Up to now, I've mostly used the templating systems of Django, web.py and PHP. But now that I'm using jQuery and nice ajaxy magic to get data from the server without refreshing the client, I'm seeing the advantages of building the HTML directly in javascript (so I can just send a small json object to the client and have him figure out what to change and how).
So now I have some bits that are rendered with templates, and some that are built in javascript, and even one horrid case where there's a mix of both, a web.py template that generates a javascript function that creates a HTML table - feels like C macros all over again! (I'll refactor that away eventually)
Is this a common problem in web development? Any recommended best practices, such as "use json for everything, render as much as possible in javascript", "use library foo", etc.? Any good heuristics for what to handle with templates, and what to handle with javascript?
Searching a bit here, I found someone asking about javascript templates, which does seem like a possible solution.
wsgi - wsgi/web.py 在浏览器中的体面错误输出
我正在使用 web.py 0.3 / apache2 / mod_wsgi 并且 cgitb 模块似乎不能开箱即用(我仍然只是从 web.py 得到“内部服务器错误”,通常的输出到 apache 的 error_log)。web.py 安装指南建议了一个对我不起作用的解决方法 - 我可能会破解它来工作,但是我应该使用更好的东西(可能是为 web.py 或 wsgi 设计的)吗?