我们从Python开源项目中,提取了以下2个代码示例,用于说明如何使用web.py()。
def get(self, count=True): # prepare a process-safe queue to hold all results results = multiprocessing.Queue() # spawn web.py server in another process, have it's dispatch as queue.put method app = self.app(dispatch=results.put, parsed=True) t = multiprocessing.Process(target=app.run) t.start() # stop condition: if count is a number decrease and loop until 0, # if count is True, loop forever while count: yield results.get() if type(count) == int: count -= 1 app.stop() t.terminate()
def _make_response(self, content, headers, status): return content # web.py implementation