import os

import avro.protocol
import tornado.web
import tornado.ioloop

import tornavro.server
import tornavro.responder


class HelloResponder(tornavro.responder.Responder):
    def hello(self, name):
        return 'Hello, %s' % name


proto = open(os.path.join(os.path.dirname(__file__), 'hello.avpr')).read()
proto = avro.protocol.parse(proto)
responder = HelloResponder(proto)

server = tornavro.server.AvroServer(responder)
server.listen(8888)
tornado.ioloop.IOLoop.instance().start()

import os

import avro.protocol
import tornado.web
import tornado.ioloop
from tornado.options import define, options

import tornavro.server
import tornavro.responder


define('port', default=8888, help='Listen on this port')


class HelloResponder(tornavro.responder.Responder):
    def hello(self, name):
        return 'Hello, %s' % name


tornado.options.parse_command_line()

proto = open(os.path.join(os.path.dirname(__file__), 'hello.avpr')).read()
proto = avro.protocol.parse(proto)
responder = HelloResponder(proto)

server = tornavro.server.AvroServer(responder)
server.listen(options.port)
tornado.ioloop.IOLoop.instance().start()

Make the hello protocol example more user-friendly
Make the hello protocol example more user-friendly

  import os
  
  import avro.protocol
  import tornado.web
  import tornado.ioloop
+ from tornado.options import define, options
  
  import tornavro.server
  import tornavro.responder
+ 
+ 
+ define('port', default=8888, help='Listen on this port')
  
  
  class HelloResponder(tornavro.responder.Responder):
      def hello(self, name):
          return 'Hello, %s' % name
  
  
+ tornado.options.parse_command_line()
+ 
  proto = open(os.path.join(os.path.dirname(__file__), 'hello.avpr')).read()
  proto = avro.protocol.parse(proto)
  responder = HelloResponder(proto)
  
  server = tornavro.server.AvroServer(responder)
- server.listen(8888)
+ server.listen(options.port)
  tornado.ioloop.IOLoop.instance().start()
  
Make the hello protocol example more user-friendly
## Code Before:
import os

import avro.protocol
import tornado.web
import tornado.ioloop

import tornavro.server
import tornavro.responder


class HelloResponder(tornavro.responder.Responder):
    def hello(self, name):
        return 'Hello, %s' % name


proto = open(os.path.join(os.path.dirname(__file__), 'hello.avpr')).read()
proto = avro.protocol.parse(proto)
responder = HelloResponder(proto)

server = tornavro.server.AvroServer(responder)
server.listen(8888)
tornado.ioloop.IOLoop.instance().start()

## Instruction:
Make the hello protocol example more user-friendly
## Code After:
import os

import avro.protocol
import tornado.web
import tornado.ioloop
from tornado.options import define, options

import tornavro.server
import tornavro.responder


define('port', default=8888, help='Listen on this port')


class HelloResponder(tornavro.responder.Responder):
    def hello(self, name):
        return 'Hello, %s' % name


tornado.options.parse_command_line()

proto = open(os.path.join(os.path.dirname(__file__), 'hello.avpr')).read()
proto = avro.protocol.parse(proto)
responder = HelloResponder(proto)

server = tornavro.server.AvroServer(responder)
server.listen(options.port)
tornado.ioloop.IOLoop.instance().start()
