Skip to content

Instantly share code, notes, and snippets.

@leonardoo
Created May 15, 2016 20:44
Show Gist options
  • Save leonardoo/cc9c0ae4ac0593553b4bfea239758528 to your computer and use it in GitHub Desktop.
Save leonardoo/cc9c0ae4ac0593553b4bfea239758528 to your computer and use it in GitHub Desktop.
import asyncio
from growler import App
from growler.middleware import (Logger, Static, Renderer, Timer)
loop = asyncio.get_event_loop()
# Construct our application with name GrowlerServer
app = App('GrowlerServer', loop=loop)
# Add some growler middleware to the application
app.use(Logger())
@app.get('/')
def click(req, res):
res.send_text(req.param("url", "test"))
# Create the server - this automatically adds it to the asyncio event loop
Server = app.create_server(host='127.0.0.1', port=8001)
# Tell the event loop to run forever - this will listen to the server's
# socket and wake up the growler application upon each connection
loop.run_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment