Python Klein - Non Blocking API
问题 Need help with Klein API for Non-blocking. This is a simple test app: # -*- coding: utf-8 -*- import datetime import json import time from klein import Klein app = Klein() async def delay(seconds): """Set some delay for test""" time.sleep(seconds) return "Works" @app.route('/', branch=True) async def main(request): some_data = await delay(5) return json.dumps([{ "status": "200", "time": datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), "data": some_data }]) app.run("localhost", 8080)