示例#1
0
文件: simple.py 项目: odra/crocus
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
文件: __init__.py 项目: odra/crocus
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)