[ Previous ] [ Contents ] [ Index ] [ Next ]

Example 1: hello

The following example script implements a simple request procedure which returns 'Hello World'.

This example can be found in the examples/tcl/hello.tcl file.

    
    # Example 1: Hello World
    # 
    # This simple operation just returns a plain text message.
    #
    # Things to notice:
    #
    # * ns_register_proc takes as arguments:
    #   * the HTTP method
    #   * the URL that the procedure handles
    #   * the procedure that is executed
    #
    # * ns_return takes as arguments:
    #   * the passed in connection
    #   * a return status, in this case 200 for success
    #   * a MIME type
    #   * the actual string to return
    #
    # * ns_return properly formats the HTTP response for you.
    
    ns_register_proc GET /example/hello hello
    
    proc hello {conn context} {
       ns_return $conn 200 text/plain "Hello World"}
     
    

Top of Page

[ Previous ] [ Contents ] [ Index ] [ Next ]
Copyright © 1998-99 America Online, Inc.