Add two CGI example and basic Python CGI server.

This commit is contained in:
Michał Zieliński
2013-12-18 18:19:32 +01:00
parent 74a63c004f
commit 101d8bc9c3
4 changed files with 25 additions and 0 deletions

2
.gitignore vendored
View File

@@ -63,6 +63,8 @@ examples/cross_calculator/android/tags
/examples/allany
/examples/cairoex
/examples/cgiex
/examples/cgi/cgi_stacktrace
/examples/cgi/example
/examples/curlex
/examples/docstrings
/examples/filterex

View File

@@ -0,0 +1,11 @@
#!/usr/bin/env python
import BaseHTTPServer
import CGIHTTPServer
server = BaseHTTPServer.HTTPServer
handler = CGIHTTPServer.CGIHTTPRequestHandler
server_address = ('localhost', 8008)
handler.cgi_directories = ['/']
httpd = server(server_address, handler)
httpd.serve_forever()

View File

@@ -0,0 +1,5 @@
import cgi
cgi.setStackTraceStdout()
var a: string = nil
a.add "foobar"

7
examples/cgi/example.nim Normal file
View File

@@ -0,0 +1,7 @@
import cgi
write(stdout, "Content-type: text/html\n\n")
write(stdout, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">\n")
write(stdout, "<html><head><title>Test</title></head><body>\n")
write(stdout, "Hello!")
writeln(stdout, "</body></html>")