Skip to content

Instantly share code, notes, and snippets.

@kplaube
Created September 16, 2012 23:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kplaube/3734844 to your computer and use it in GitHub Desktop.
Save kplaube/3734844 to your computer and use it in GitHub Desktop.
Casos de uso do CGI
<VirtualHost *:80>
ServerName www.example.com
ServerAlias example.com
ServerAdmin webmaster@example.com
DocumentRoot /usr/local/www/documents
Alias /robots.txt /usr/local/www/documents/robots.txt
Alias /favicon.ico /usr/local/www/documents/favicon.ico
Alias /media/ /usr/local/www/documents/media/
<Directory /usr/local/www/documents>
Order allow,deny
Allow from all
</Directory>
WSGIScriptAlias / /usr/local/www/wsgi-scripts/wsgi.py
<Directory /usr/local/www/wsgi-scripts>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
#include <stdio.h>
int main(int argc, char *argv[])
{
printf("Content-type:text/html\n\n");
printf("<html>\n");
printf("<body bgcolor=\"%s\">\n", argv[1]);
printf("</body>");
printf("</html>");
return 0;
}
#!/usr/bin/python
from os import environ
print "Content-Type: text/html\n\n"
print "<html><body>Hello %s!</body></html>" % environ.get('REMOTE_ADDR')
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
char *addr, *method, *query_string;
addr = getenv("REMOTE_ADDR");
method = getenv("REQUEST_METHOD");
query_string = getenv("QUERY_STRING");
printf("Content-type:text/html\n\n");
printf("Remote address: %s<br/>", addr);
printf("Method: %s<br/>", method);
printf("Query string: %s<br/>", query_string);
}
#!/usr/bin/python
def application(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/html')])
return ['<html><body>Hello %s</body></html>' % environ.get('REMOTE_ADDR')]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment