Get parameters from BaseHTTPServer http POST request

Get parameters from BaseHTTPServer http POST request. 获取 BaseHTTPServer.BaseHTTPRequestHandler POST 请求参数。

def do_POST(self):
    params = cgi.parse_qs(self.rfile.read(int(self.headers.getheader('Content-Length'))))

Happy Birthday to My Girl!

妞妞生日快乐!

爱你乖~

到底是怎么了?

为什么面试的时候不会就说不会不懂就是不懂实话实说的人频频被人鄙视,而不会装会不懂装懂满嘴跑火车吹的天花乱坠好像自己有多牛逼不要我就是你公司一大损失的人却能受面试官喜欢呢?是我们太老实还是太傻?

有感于丫头面试。

The _imaging C module is not installed

Download jpeglib.

cd jpeg-7
sudo make clean
sudo CC="gcc -arch i386" ./configure --enable-shared --enable-static
sudo make
sudo make install

Download PIL.

sudo rm -Rf build
//Edit JPEG_ROOT = libinclude("/usr/local") in setup.py
sudo python setup.py build
sudo python setup.py install

Get the server IP of BaseHTTPServer.BaseHTTPRequestHandler

获取 BaseHTTPServer.BaseHTTPRequestHandler 请求服务器的 IP。

serveradress = re.findall('Host: (.*?)\r\n',str(self.headers))

Show PIL image object in browser

在浏览器显示 PIL 处理过的图片对象。

Using PIL module, you can resize or crop an image and return an image object. After that, I want to show the resized-image-object in browser. Here it is.

pic = thumbPicture()
f = StringIO()
pic.save(f,'JPEG')
f.seek(0)
shutil.copyfileobj(f,self.wfile)
self.sendHeader(contenttype = 'image/jpeg',contentlength = f.tell())
f.close()

Get parameters from BaseHTTPServer http GET request

BaseHTTPHandler from the BaseHTTPServer module doesn’t seem to provide any convenient way to access http request parameters. What is the best way to parse the GET parameters from the path, and the POST parameters from the request body?

Right now, I’m using this for GET:

parsed_path = urlparse.urlparse(self.path)
try:
    params = dict([p.split('=') for p in parsed_path[4].split('&')])
except:
    params = {}

还有很长的路要走

自己现在的技术掌握太糙了。

整体上,难以把握整体结构设计,各个模块功能设计,各模块间通信传输等等。

细节上,Python 如此简洁优美的语法让我写的是惨不忍睹,Python 自带的模块、函数还很不熟悉。

我才刚刚上路。

毕业一年了

准确说应该是昨天,6 月 26 日离开学校整一年。

结束三高的一年,我来到北京,继续我的努力。

我,还在路上。

cdto open iTerm

cdto:Fast mini application that opens a Terminal.app window cd’d to the front most finder window,快速在当前路径打开一个 Termainal。iTerm 是 Mac 下一个增强终端。默认状态下 cdto 是打开系统自带的 Terminal.app,其实 cdto 也是支持 iTerm 的。

右键 Show Package Contents 打开 cdto.app,将 Contents/Plugins Disabled 下的 iterm.bundle mv 替换 Contents/Plugins 下 terminal.bundle 即可。