Пример #1
0
from crocus import Crocus

app = Crocus()

@app.get('/')
async def hello(req, res):
  res.code = 200
  res.header('content-type', 'text/plain')
  res.write(b'chunk data')
  await res.end(b'another chunk data')


if __name__ == '__main__':
  app.run(host='127.0.0.1', port=5000)

Пример #2
0
from crocus import Crocus
from . import handlers, middlewares

app = Crocus()

#root routes
app.all('/', handlers.root.root)

#users routes
app.post('/users', handlers.users.create)
app.get('/users', handlers.users.search)

#application middlewares
app.use(middlewares.bodyparser, middlewares.auth)