python web


using connectport x4.
how to retrieve result from python script on a web page. x4 does not support cgi as i understand. can anyone give a clue on how to simply print python result in an uploaded html form?

There are a few ways to accomplish what you are trying to do. One way in particular can involve direct callouts from the Digi web server to a python script via the “digiweb” module. Have you examined this module?

for reference:

will check that later.

can anyone give a clue, or a working example, because in documentation its not clear: should html be formed by python or python calls can be initiated from html.
cant get both ways working.


If you’re using the digiweb module that was linked previously, the callback that is registered forms the HTML to be returned as a string and returns that as the second element of the return tuple. For HTML, the first element should be the constant digiweb.TextHtml. That will cause the internal web server on the Digi box to return the web page you’ve generated.

There are two good examples on the wiki page. In the first one, you can see the template object is the form that all pages that example returns will take. It just fills in a few fields in the string to customize it for the particular request. If you have specific page locations that you would like to serve with different content, you would do the same, but base what you return on the path value passed into the callback.


could you please link to those examples you are talking about.
can anyone suggest simple explanation of how things must be done. following examples i cant get the generated content, the browser retrieves example source (like it was a .txt file). behavior is different using FF ant IE.
has anyone tried this with X4? it seems web server does not support digiweb. firmware


the digiweb module was added in 2.8.0. so it should be in your firmware. I think the simplest you can get is the following:
Telnet to your device, type python and hit enter to enter the interactive console and type the following:

import digiweb
x= digiweb.Callback(lambda type, path, headers, args:(digiweb.TextHtml, “Worked”) )

then from web browser go to http://[device address]/test
should print out “Worked”

If they work then look at the examples at the end of the page in Can also check out

Message was edited by: clohfink
(added links)

thanks for reply,
something is wrong. from your post i understand the principle is to run python console waiting, only then interact with web interface.
first, py console doesn’t wait, if no parameters given - it executes with error, if given a python file with you example source - it executes immediately and exits.
second - there is no path like “test”, the whole web content is hosted from /FS/WEB, python content /FS/WEB/python.

thanks again for cooperation,
reply is very much appreciated


The intention was to follow the instructions step-by-step.

The first was to telnet to the device and to enter the two lines to our interactive console, not to place them into an uploaded script. Since the interactive console remains active after the two commands are entered, you are able to observe the effect that they have had to the system.

The relative path “test” is arbitrary… chosen specifically because it is not an existing path.

The way the “digiweb” module works is that it is given the opportunity to service any otherwise unresolved path. In a more complete example, the callback function would examine the path parameter, and serve an appropriate page, or no pages.

The information pages that were referenced above have more complete examples that can, if you wish, be simply entered and run from the filesystem. They are worth examining.

Message was edited by: 52637p

I’m trying to use the module “digiweb” on a Digi Transport WR41, but It seems not working.
In order to test it I used the code posted before:

import digiweb
x= digiweb.Callback(lambda type, path, headers, args:(digiweb.TextHtml, “Worked”) )

The results is that every url I try (es: http://router_address/test) drive me to the logi page.
Can someone help me?