0

I have a problem. I have a project that involves sending a value from a web page to a web server and using that value to generate a voltage by commanding a digital to analog converter. For the server side I am using a Python script that works very well and I have created a simple web page in which I can enter the value wanted. But the link between them is missing. I am trying to understand CGI scripts to use them for parsing the value from the web page to the Python script but with no luck. Does anyone have any other ideas or can anyone explain CGI for beginners? Thank you.

1

1 Answer 1

0

Here is a simple Python script that pipes the output of a locally executed command (dir on a Windows computer in this case) via a web request (using the excellent web.py library):

import web
from subprocess import check_output

urls = (
    '/', 'index'
)
app = web.application(urls, globals())

class index:
    def GET(self):
        return '<pre>'+check_output('dir', shell=True)+'</pre>'

if __name__ == "__main__":
    app.run()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.