Search code examples
pythonpostnetwork-programmingwebserver

Transmit Pythonscript-Result to Webpage


Actual situation:

The client downloads a small pythonscript that is executable. The client executes it. The script gathers information from the computer and sends the data to the webserver vià POST-Method.

Wanted Situation:

After the webserver recived the data, it should forward the information to the website-session of the client. And the website should display the information.

This is a visual example of the principle:

Example principle

There is also a example of this principle on Can You Run It.

How can I realize this?


Solution

  • A common way of implementing this is using a RESTful API. Basically the API does not care if the request is from a script or web browser, it just passes data structures to and from clients. The only tricky part to your example is when there are multiple users involved because a secret must be shared between the browser and script. I believe Can You Run It puts this unique secret into the program they ask you to download.

    Look into Django Rest Framework for examples of how to implement this.