Note on Using requests package

How to see request header and body? When making requests, we may want to see exactly what are being requested. With requests, it is easy do access the request header and request body: import requests url = "http://httpbin.org/post" payload = {"apple": 10, "pear": [20, 30], "img": "http://example.com/demo.jpg"} r = requests.post(url, json=payload) print(f"request headers: {r.request.headers}") print(f"request body: {r.request.body}") A sample output is: request headers: {'User-Agent': 'python-requests/2.19.1', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'Content-Length': '69', 'Content-Type': 'application/json'} request body: b'{"apple": 10, "pear": [20, 30], "img": "http://example.

如何找到技术问题根源?

在实际编程中,我们总会遇到各种各样的代码运行问题,如何快速发现问题的根源需要一些系统的方法,构造一个最小的能够复现错误的环境至关重要,也就是所谓的 MWE,minimal working example。

Serving Flask Application with uWSGI

In my old post, I have shared how to run the builtin development server to serve the web API. For production, we need to use more powerful web servers. Flask complies to the WSGI (Web Server Gateway Interface) specification and can work with any web server that conforms to WSGI.

In this post, I want share how to run Flask applications using uWSGI — a popular WSGI-compliant server.

AI 的噱头

人工智能 (AI)甚嚣尘上,动则称颠覆,各家公司纷纷推出了自己的 AI 产品,但是这些产品真的有那么多人用吗?

Justmysocks 支持 v2ray 协议了!

two meetings 即将或者正在召开,上个谷歌也越来越难,最近墙对各种工具的阻断非常严重,连之前使用了 obfs 的 ss 都不行了,最近一段时间也处于时断时续的状态。

Justmysocks 之前一直用的都是 shadowsocks 协议,对墙的反制能力不行,每到关键时候就显露疲态。好消息是,justmysocks 终于在最近推出了基于 v2ray 协议的线路。

Space for CJK Languages (CJK 语言中的空格)

I was doing some typograph for Chinese text and want to insert a space equal to the width of a Chinese character.

最近在做一些中文排版的工作,有一个需求是在中文字符之间插入空格,并且空格的宽度等于中文字符的宽度,在某些情况下这样排版显得更加美观。