Question

I want to build a hybrid application (Web technologies embedded in a desktop app).

I will start with a Web version and the embed it using WebKit, but I don't want the embedded version to service requests through a TCP port.

With WebKit (Qt,Gtk) I can intercept all URL requests and act on them.

What I'm missing is a way to invoke the Flask URL-to-callable dispatcher without going through TCP (or WSGI).

Any ideas better than analyzing the call stack with a debugger?

Was it helpful?

Solution

Simon Sapin answered on the (quite active) Flask mailing list:

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top