Discuss / Python / 小结

小结

Topic source

request的实现看起来很神奇,没有与app绑定的代码,连app里初始化request的代码也没有。 表面看起来的实现是,在每个app.route接收到http请求时,request都被初始并传入http的参数。于是可以直接调用。

具体实现原理好奇,但没看懂,除了提及request是global object,可每个app里也没有传入request对象或是初始化它啊,希望有人解释下。官网的说明也是神奇

class flask.request ... Flask makes sure that you always get the correct data for the active thread if you are in a multithreaded environment.

廖雪峰

#2 Created at ... [Delete] [Delete and Lock User]

回头看ThreadLocal一节


  • 1

Reply