将信息传递给 mod_wsgi 并返回 div 标签

发布于 2024-10-06 16:20:17 字数 431 浏览 3 评论 0原文

长期读者第一次海报。

最近,我的任务是为我的雇主将一些 python 合并到一个网页中。经过一些研究后,似乎 mod_wsgi 和 Django 是最佳选择,而且效果似乎很好。然而,我的雇主希望在 Drupal 中维护该网站并合并 python,因此我认为 Django(或任何其他 python 框架)不可行,因为会有两个竞争框架在运行。我已经设法设置了一个 wsgi-scripts bin 并且可以运行 python 代码,但是我遇到了一些问题:

1.) 我找到的将信息传递给 wsgi/python 脚本的唯一方法是通过 POST 和GET,有替代方法还是这是标准方法?

2.) 当我从 wsgi/python 脚本返回时,总是会加载一个新页面。是否可以让脚本返回到 div 环境?例如)有人填写表格,提交,数据由python处理,输出返回并显示在页面底部。

谢谢, 保罗

long time reader first time poster.

I've recently been tasked with incorporating some python into a webpage for my employer. After doing some research it seemed that mod_wsgi and Django were the way to go, and it seemed to work great. However, my employer would like to maintain the site in Drupal and incorporate python as such I don't think the Django (or any other python framework) is viable as there would be two competing frameworks running around. I've managed to setup a wsgi-scripts bin and can get python code to run however I have run into a few problems:

1.) The only method I've found for passing information to a wsgi/python script is via POST and GET, is there an alternative or is this the standard method?

2.) When I return from a wsgi/python script a new page is always loaded. Is it possible to have the script return to a div environment? e.g.) Someone fills in a form, submits it, data is processed by python, output is returned and displayed at the bottom of the page.

Thanks,
Paul

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不气馁 2024-10-13 16:20:17

Drupal 是一个 PHP 语言框架,恕我直言,wsgi/Django 对你来说太重了。它们的设计目的是用于整个网站。

php中的passthru怎么样?

passthru — 执行外部程序并显示原始输出

您可以执行 python 脚本(甚至可以使用 POST 中的命令行参数)并显示脚本输出的原始 HTML。

Drupal is a PHP-language framework, and wsgi/Django are waay too heavy for you IMHO. They're kinda designed to be used for the whole website.

How about passthru in php?

passthru — Execute an external program and display raw output

You could execute the python script (maybe even with command line arguments from POST) and display raw HTML that the script outputs.

任谁 2024-10-13 16:20:17

1.) 我发现的将信息传递到 wsgi/python 脚本的唯一方法是通过 POST 和 GET,是否有替代方法或者这是标准方法?

脱离上下文这是没有意义的。

如果 Apache(或您使用的任何 Web 服务器)运行 mod_wsgi,而 mod_wsgi 运行 Python,那么答案是“这不仅是标准,它绝对是您所拥有的一切。外部环境变量。”

我不知道你为什么这么问,因为 HTTP 的标准非常清晰而且非常简单。

2.) 当我从 wsgi/python 脚本返回时,总是会加载新页面。是否可以让脚本返回到 div 环境?例如)有人填写表格,提交,数据由python处理,返回输出并显示在页面底部。

“让脚本返回 div 环境”根本没有任何意义。

“有人填写表格,提交,数据由 python 处理,输出返回并显示在页面底部。”根本没有任何意义。您似乎正在描述一些根本不是 HTTP 的东西。

我不知道你为什么这么问,因为 HTTP 的标准非常清晰而且非常简单。

请求(GET、POST、PUT、DELETE 等等)发送到 Web 服务器并返回一个页面。简而言之,这或多或少就是 HTTP。没有其他输入。没有部分输出。

如果您希望 Python 应用程序(在 mod_wsgi 下运行)从 Drupal 获取数据,那么只需从 Python 到运行 Drupal 的任何服务器进行 API 调用即可。

如果要显示旧页面和新信息,则必须组装一个包含旧页面和新信息的页面。你必须写这个新页面。使用模板或其他工具。

1.) The only method I've found for passing information to a wsgi/python script is via POST and GET, is there an alternative or is this the standard method?

This makes no sense out of context.

If Apache (or whatever web server you're using) runs mod_wsgi, which runs Python, then the answer is "This is not only the standard, it's absolutely all you've got. Outside environment variables."

I'm not sure why you're asking, since the standard for HTTP is quite clear and quite simple.

2.) When I return from a wsgi/python script a new page is always loaded. Is it possible to have the script return to a div environment? e.g.) Someone fills in a form, submits it, data is processed by python, output is returned and displayed at the bottom of the page.

"have the script return to a div environment" doesn't make any sense at all.

"Someone fills in a form, submits it, data is processed by python, output is returned and displayed at the bottom of the page." Doesn't make any sense at all. You seem to be describing something that's not HTTP at all.

I'm not sure why you're asking, since the standard for HTTP is quite clear and quite simple.

A request (GET, POST, PUT, DELETE, whatever) goes to the web server and a page comes back. That's more-or-less HTTP in a nutshell. There are no other inputs. There are no partial outputs.

If you want a Python application (running under mod_wsgi) to get data from Drupal, that's just an API call from Python to whatever server is running Drupal.

If you want the old page plus new information to be displayed, you have to assemble a page which contains the old page plus the new information. You have to write this new page. Use a template or some other tool.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文