encode / apistar

The Web API toolkit. 🛠
https://docs.apistar.com
BSD 3-Clause "New" or "Revised" License
5.57k stars 411 forks source link

Need help #626

Closed alikopasa closed 5 years ago

alikopasa commented 5 years ago

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)
tomchristie commented 5 years ago

Hiya,

We use the issue tracker for bugs and feature request on the package. For discussion and usage questions please see https://discuss.apistar.org (Although also not the big 0.6 change removes the server completely, see #624)