简体   繁体   中英

Generating data on server-side and sending it to client?

How would you write a webpage that would request (execution of) a python script on the server and then take output from that script and send it back to the browser?

I'm currently taking a web programming course and have probably spent more time looking up documentation and asking questions than writing code! Thanks for any help!

python -m SimpleHTTPServer [port]

You have several options, but most of them involve the Web Server Gateway Interface WSGI . Look for a web server (Apache, Cherokee, etc) that supports WSGI and use something like this Hello World

def application(environ, start_response):
  start_response('200 OK', [('Content-Type', 'text/plain')])
  yield 'Hello World\n'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM