-
Notifications
You must be signed in to change notification settings - Fork 5
Home
Albert Wang edited this page Apr 26, 2017
·
6 revisions
Welcome to the hyper2web wiki!
from hyper2web import app
app = app.App()
The constructor of App class.
route: the restful api handler: an async function which accepts only one argument, an EndPointHandler
async def get_name(handler):
print('GET name hit')
await handler.send_and_end('GET name hit')
app.get('name', get_name)
A top level API user should never construct it. It is only passed by the framework to the app.get
's async callback function.
send data
to the client. data
type could be any, but recommendation is str
this will end a HTTP/2 stream
send a file in your filesystem this will end a HTTP/2 stream
If you want to send a file, this function is recommended. If you use the send_and_end
function, you have to do the flow control yourself, which is not fun.