Created
February 9, 2014 15:21
-
-
Save jackpoter/8900568 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from BaseHTTPServer import BaseHTTPRequestHandler,HTTPServer | |
class MyHandler(BaseHTTPRequestHandler): | |
protocol_version = 'HTTP/1.1' | |
server_version = 'nginx' | |
sys_version = '1.0' | |
def do_GET(self): | |
self.send_response(302) | |
self.send_header('Location','http://z.cn') | |
self.end_headers() | |
if __name__=='__main__': | |
sport = 8000 | |
server = HTTPServer(('',sport),MyHandler) | |
server.serve_forever() | |
#server.socket.close() | |
#2014-2-9 23:00:48.386 HTTP/1.1 302 Found | |
#2014-2-9 23:00:48.386 Server: nginx 1.0 | |
#2014-2-9 23:00:48.396 Date: Sun, 09 Feb 2014 15:00:48 GMT | |
#2014-2-9 23:00:48.396 Location: http://z.cn | |
''' | |
root@vps:~# ps axv | |
PID TTY STAT TIME MAJFL TRS DRS RSS %MEM COMMAND | |
2277 ? Ss 0:04 2 7470 31917 1092 1.4 php-fpm: master process (/etc/php5/fpm/php-fpm.conf) | |
3014 ? Ss 0:00 6 737 9234 184 0.2 nginx: master process /usr/sbin/nginx | |
3015 ? S 128:28 5 737 9794 1220 1.6 nginx: worker process | |
28892 pts/0 Ss+ 0:00 0 2321 6782 5040 6.8 py 8000server.py | |
''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment