async def helloWorld(request, tag=None): return response.html(''' <div> <h1> hello, {} </h1> </div>'''.format(tag))
async def helloWorld(request, foodname=None, gram=100): food = SearchFood(foodname, gram=gram) await food.search() food_specs = food.specs rsp_html = ''' <div> <p>名字:{}</p> <p>热量:{}</p> <p>碳水化合物:{}</p> <p>脂肪:{}</p> <p>蛋白质:{}</p> </div>'''.format(food_specs['real_name'], food_specs['cal'], food_specs['碳水化合物'], food_specs['脂肪'], food_specs['蛋白质']) return response.html(rsp_html)
def post(self, request): return response.html('<h1>post</h1>')
def get(self, request): return response.html('<h1>class view test</h1>')
def write_error(self): response = html('bad connecton', status=400) self.write_response(response) self.transport.close()