python - 在没有 TCP 端口的情况下通过 Flask 调度 URL

标签 python webkit flask hybrid

我想构建一个混合应用程序(嵌入到桌面应用程序中的 Web 技术)。

我将从 Web 版本开始,并使用 WebKit 嵌入它,但我不希望嵌入版本通过 TCP 端口服务请求。

使用 WebKit(Qt、Gtk),我可以拦截所有 URL 请求并对其进行操作。

我缺少的是一种无需通过 TCP(或 WSGI)即可调用 Flask URL 可调用调度程序的方法。

还有比使用调试器分析调用堆栈更好的想法吗?

最佳答案

Simon Sapin 在(相当活跃的)Flask 邮件列表上回复:

Why not WSGI ?

You have to get a Python interpreter somewhere. Then you need to call your application somehow with data from WebKit like the URL being requested, and get the response. WSGI is just that: a calling convention for Python functions (or other callable objects.)

If WSGI is more complex than you’d like, you can use the test client:

That’s how I do it in Frozen-Flask. It simulates HTTP requests to a Flask app at the WSGI level and write the responses to static files. The test client is just an easier way to make WSGI calls:

https://github.com/SimonSapin/Frozen-Flask/blob/master/flaskext/frozen/__init__.py#L228

WSGI really is Flask’s "entry point".

Other than that if you’re interested in Flask inner workings start looking from here:

https://github.com/mitsuhiko/flask/blob/master/flask/app.py#L1477

关于python - 在没有 TCP 端口的情况下通过 Flask 调度 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7758988/

相关文章:

python - Django 完整性错误 _id 可能不为空,外键 id 分配

python - PyCUDA 使用字符串但不使用字符串数组

javascript - CSS 动画播放状态问题 : Animation jumps back to initial frame when resumed?

python - Flask框架可以将实时数据从服务器发送到客户端浏览器吗?

testing - 使用 peewe 和 PyTest 测试 Flask-Security 时数据库没有改变

python - 502 Bad Gateway 重新加载主管后

python - 如何从 Python 中的类中获取对象的名称?

python - Selenium 中的多个浏览器与 Python

css - Webkit 支持渐变过渡

c# - 在C#中,使用WebKitBrowser,如何获取HTML?