Bernardo (The name is inspired by the Zorro's servant) is a small HTTPD (Less that 200 lines of code) that allows you to Execute C, Python, Perl, PHP code or just "display" a file.
The Usage is Very simple: bernardo-httpd
And now a simple code Example. You need to complete the HTTP Response Headers and then you can output your data. http://localhost:8080/test.py will display the "Hello Python" page.
#!/usr/bin/env python
import os
if __name__ == '__main__':
print "Content-Type: text/html"
print
print "<html>"
print "<head><title>Hello Python</title></head>"
print "<body>"
print "<h1>Hello Python</h1>"
print "<p><b>Request Method</b>: ", os.environ['REQUEST_METHOD']
print "<p><b>Query String</b>: ", os.environ['QUERY_STRING']
print "</body>"
print "<html>"
The Source Code is Available Here: Bernardo HTTPD Source Code.
#!/usr/local/bin/perl
ReplyDelete# hello.pl -- my first perl script!
print "Content-type: text/html\n\n";
print <<"EOF";
Hello, world!
Hello, world!
EOF