Need help for response


#1

Hello,

I want to create an app and response route after event bus response.
Is it possible with apistar? or any alternative method for this situation?

Thank you very much for help!
Best Regards

This code try to response from hello_world def.
Here is the example code;

from apistar import ASyncApp, Route
import uvicorn
import time
from event_bus import EventBus

bus = EventBus()

@bus.on('hello')
def subscribed_event():
    print('World!')
    return {'hello': 'response from event bus'}

def some_func():
    bus.emit('hello')

async def hello_world() -> dict:
    some_func() #i want to response after this event response...
    #return {'hello': 'i do not want to response here...'}

routes = [
    Route('/', method='GET', handler=hello_world)
]

app = ASyncApp(routes=routes)

if __name__ == '__main__':
    app.serve('0.0.0.0', 999, debug=True)
    #uvicorn.run(app, host='0.0.0.0', port=999, debug=True, access_log=False)