Add two CGI example and basic Python CGI server.
This commit is contained in:
parent
74a63c004f
commit
101d8bc9c3
4 changed files with 25 additions and 0 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -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
|
||||
|
|
|
|||
11
examples/cgi/cgi_server.py
Normal file
11
examples/cgi/cgi_server.py
Normal 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()
|
||||
5
examples/cgi/cgi_stacktrace.nim
Normal file
5
examples/cgi/cgi_stacktrace.nim
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
import cgi
|
||||
cgi.setStackTraceStdout()
|
||||
|
||||
var a: string = nil
|
||||
a.add "foobar"
|
||||
7
examples/cgi/example.nim
Normal file
7
examples/cgi/example.nim
Normal 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>")
|
||||
Loading…
Add table
Add a link
Reference in a new issue