


The output response function refers to a set of tool functions that generate processing results for the client. Developers call them to control the processing results of the URL. Commonly used output corresponding functions are as follows:
1. RequestHandler.set_status(status_code,reason=None)
Set the return code in HTTP Response. If there is a descriptive statement, it can be assigned to reason parameter.
2. RequestHandler.set_header(name,value)
Set the HTTP header parameters in the HTTP Response in the form of key-value pairs. The Header value configured using set_header will overwrite the previously configured Header.
3. RequestHandler.add_header(name,value)
Set the HTTP header parameters in HTTP Response in the form of key-value pairs. Different from set_header, the Header value configured by add_header will not overwrite the previously configured Header.
4. RequestHandler.write(chunk)
Send the given chunk to the client as HTTP Body. Under normal circumstances, use this function to output a string to the client.
If the given block is a dictionary, the block will be sent to the client in JSON format, and the Content_Type in the HTTP Header will be set to application/json.
5, RequestHandler.finish( chunk=None)
This method notifies Tornado.Response that the generation work has been completed. The chunk parameter is the HTTP body that needs to be passed to the client. After calling finish(), Tornado will send an HTTP Response to the client.
This method is suitable for asynchronous request processing of RequestHandler. In the function of synchronous or coroutine access processing, there is no need to call the finish() function.
6. RequestHandler.render(template_name,**kwargs)
Render the module with the given parameters. You can pass in the template file name and template parameters in this function.
Example
import tornado.web class MainHandler(tornado.web.RequestHandler): def get(self): items=["Python","C++","Java"] #第一个参数是模板名称,后面是模板参数 self.render("template.html",title="Tornado Template",items=items)
7. RequestHandler.redirect(url,permanent=False,status=None)
Perform page redirection. During the RequestHandler processing process, the redirect() function can be called at any time to redirect the page.
8. RequestHandler.clear()
Clear all Header and Body content previously written in this request.
9. RequestHandler.set_cookie(name,value)
Set the value of Cookie in Response by key-value pair
10.RequestHandler.clear_all_cookies(path="/", domain=None)
Clear all cookies in this request
The above is the detailed content of RequestHandler for Python development of Tornado website: output corresponding function. For more information, please follow other related articles on the PHP Chinese website!

本篇文章给大家带来了关于Python的相关知识,其中主要介绍了关于Seaborn的相关问题,包括了数据可视化处理的散点图、折线图、条形图等等内容,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于Python的相关知识,其中主要介绍了关于进程池与进程锁的相关问题,包括进程池的创建模块,进程池函数等等内容,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于Python的相关知识,其中主要介绍了关于简历筛选的相关问题,包括了定义 ReadDoc 类用以读取 word 文件以及定义 search_word 函数用以筛选的相关内容,下面一起来看一下,希望对大家有帮助。

VS Code的确是一款非常热门、有强大用户基础的一款开发工具。本文给大家介绍一下10款高效、好用的插件,能够让原本单薄的VS Code如虎添翼,开发效率顿时提升到一个新的阶段。

本篇文章给大家带来了关于Python的相关知识,其中主要介绍了关于数据类型之字符串、数字的相关问题,下面一起来看一下,希望对大家有帮助。

pythn的中文意思是巨蟒、蟒蛇。1989年圣诞节期间,Guido van Rossum在家闲的没事干,为了跟朋友庆祝圣诞节,决定发明一种全新的脚本语言。他很喜欢一个肥皂剧叫Monty Python,所以便把这门语言叫做python。

本篇文章给大家带来了关于Python的相关知识,其中主要介绍了关于numpy模块的相关问题,Numpy是Numerical Python extensions的缩写,字面意思是Python数值计算扩展,下面一起来看一下,希望对大家有帮助。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Linux new version
SublimeText3 Linux latest version

Notepad++7.3.1
Easy-to-use and free code editor

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver CS6
Visual web development tools
