wsgi not http-response



  • How do we use wsgi-scrypt to perform some action (shell-comand or recording of the form in the file...) without opening a new html page?
    Here's an example code:

    import subprocess
    import os
    

    HELLO_WORLD = b"Hello world!\n"
    f = subprocess.Popen(["mpc", "play"])

    def simple_app(environ, start_response):
    status = '200 OK'
    response_headers = [('Content-type', 'text/plain')]
    start_response(status, response_headers)
    return [HELLO_WORLD]

    Called by a form button (action="myapp.wsgi")



  • You can send your status. 204 No Content

    def simple_app(environ, start_response):
        start_response('204 No Content', [])
        # код выполняющий какие-то действия
        return []
    

    However, the client(s) is obliged not to change the page of the request. (Sighs) http://httpbin.org/status/204 )


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2