惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

aimingoo的专栏
aimingoo的专栏
Google DeepMind News
Google DeepMind News
S
SegmentFault 最新的问题
Project Zero
Project Zero
D
DataBreaches.Net
I
InfoQ
L
Lohrmann on Cybersecurity
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
酷 壳 – CoolShell
酷 壳 – CoolShell
Stack Overflow Blog
Stack Overflow Blog
The Register - Security
The Register - Security
Recorded Future
Recorded Future
Vercel News
Vercel News
博客园 - 司徒正美
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
I
Intezer
The Hacker News
The Hacker News
F
Fortinet All Blogs
Microsoft Azure Blog
Microsoft Azure Blog
P
Proofpoint News Feed
Help Net Security
Help Net Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Scott Helme
Scott Helme
T
Threatpost
爱范儿
爱范儿
N
Netflix TechBlog - Medium
D
Docker
云风的 BLOG
云风的 BLOG
C
Cisco Blogs
K
Kaspersky official blog
H
Help Net Security
S
Secure Thoughts
T
Threat Research - Cisco Blogs
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
S
Security @ Cisco Blogs
Cyberwarzone
Cyberwarzone
N
News and Events Feed by Topic
G
Google Developers Blog
Forbes - Security
Forbes - Security
博客园 - 三生石上(FineUI控件)
博客园 - 叶小钗
B
Blog
Google DeepMind News
Google DeepMind News
Recent Announcements
Recent Announcements
Simon Willison's Weblog
Simon Willison's Weblog
S
Securelist
P
Privacy International News Feed
Spread Privacy
Spread Privacy
The Last Watchdog
The Last Watchdog

博客园 - 柯君

基于OceanBase的行列混合存储架构适配HTAP的方案改造 知识图谱内容综述(一) url末尾的斜杠作用探秘 访问控制技术的一些研究分析 Python学习摘要201802 机器学习-梯度下降参数调优小结 用尽洪荒之力学习Flask源码 Flask第三方工具组件介绍 Flask自带的常用组件介绍 Centos下部署Flask Python Tips阅读摘要 技术博文阅读摘要分享-9月 Python2和Python3的差异 通过Django Channels设计聊天机器人WEB框架 Windows下配置vue的环境 Redis的安装及学习 MongoDB学习笔记 Windows下安装MongoDB Chatbot思考录
Flask类的属性和方法大全
柯君 · 2017-09-26 · via 博客园 - 柯君


Flask版本0.12。

Flask Property

__class__

介绍: 用于存放当前对象实例所属的类型,值是:<class 'flask.app.Flask'>。**注意在未修改__class__的情况下,type(A)=A.class

__dict__

介绍: 用于存放当前对象的所有属性。其内容是本文数据字典的子集。

__doc__

介绍: 保存类的文档字符串。可以通过help函数或者inspect.getdoc(Class)获得。

__module__

app_ctx_globals_class

config_class

debug

default_config

error_handlers

get_send_file_max_age

has_static_folder

jinja_environment

jinja_loader

jinja_options

json_decoder

json_encoder

logger_name

open_resource

permanent_session_lifetime

request_class

request_globals_class

response_class

secret_key

send_file_max_age_default

send_static_file

session_interface

static_folder

static_url_path

test_client_class

testing

url_rule_class

use_x_sendfile

Flask Method

(classmethod) delattr

介绍:删除属性attr;内建函数self.delattr(attr)时被调用。

(classmethod) format

(classmethod) getattribute

介绍: 访问Flask的属性时调用该函数。总是被调用。

(classmethod) hash

介绍: 散列函数值,调用该方法可以得到对象的7位哈希数字。

(staticmethod) new

介绍: 静态方法,用于创建类实例;它在__init__之前被调用。

(classmethod) reduce

(classmethod) reduce_ex

(classmethod) setattr

介绍: 设置属性attr;内建函数self.setattr(self,attr,val)的调用;

(classmethod) sizeof

(classmethod) str

介绍: :当前对象被字符串化时被调用;内建函数str(self)函数,或print(self)的调用;

(classmethod) subclasshook

(classmethod) weakref

(classmethod) inject_url_defaults

(classmethod) iter_blueprints

(setupmethod) register_blueprint

参数: blueprint,**options
介绍:

(classmethod) update_template_context

(setupmethod) add_template_filter

(classmethod) jinja_env

(property)propagate_exceptions

(classmethod) open_session

(classmethod) preprocess_request

(classmethod) raise_routing_exception

(setupmethod) before_request

(classmethod) should_ignore_error

(classmethod) init

参数: import_name, static_path = None, static_url_path = None,static_folder = 'static', template_folder = 'templates',instance_path = None, instance_relative_config = False,root_path = None
介绍:

(classmethod) try_trigger_before_first_request_functions

(classmethod) test_request_context

(setupmethod) url_value_preprocessor

(classmethod) make_config

参数: instance_relative=False
介绍:

(property)preserve_context_on_exception

(setupmethod) url_defaults

(classmethod) handle_http_exception

(setupmethod) before_first_request

参数: f
介绍:

(classmethod) select_jinja_autoescape

(classmethod) wsgi_app

参数: environ,start_response
介绍:

(classmethod) handle_user_exception

(classmethod) test_client

参数: use_cookies=True,**kwargs
介绍:

(classmethod) create_jinja_environment

(classmethod) call

参数: environ,start_response
介绍:

(classmethod) do_teardown_appcontext

(property)logger

(setupmethod) add_template_global

(setupmethod) template_filter

(setupmethod) shell_context_processor

(classmethod) process_response

(classmethod) run

参数: host=None,port=None,debug=None,**options
介绍:

(setupmethod) template_test

(classmethod) handle_url_build_error

参数: error,endpoint,values
介绍:

(classmethod) do_teardown_request

(staticmethod) _get_exc_class_and_code

参数: exc_class_or_code
介绍:

(classmethod) create_global_jinja_loader

(setupmethod) errorhandler

参数: code_or_exception
介绍:

(classmethod) log_exception

(setupmethod) context_processor

(classmethod) full_dispatch_request

(setupmethod) teardown_appcontext

(classmethod) register_error_handler

参数: code_or_exception,f
介绍:

(classmethod) create_url_adapter

(classmethod) make_null_session

(classmethod) init_jinja_globals

(classmethod) _find_error_handler

(classmethod) finalize_request

参数: rv,from_error_handler=False
介绍:

(classmethod) save_session

(setupmethod) endpoint

(classmethod) name

(classmethod) make_default_options_response

(setupmethod) _register_error_handler

参数: key,code_or_exception,f
介绍:

(classmethod) dispatch_request

(setupmethod) add_url_rule

参数: rule,endpoint=None,view_func=None,**options
介绍:

(classmethod) route

(classmethod) open_instance_resource

参数: resource,mode='rb'
介绍:

(classmethod) handle_exception

(classmethod) app_context

(classmethod) make_shell_context

(property)got_first_request

(setupmethod) template_global

(classmethod) repr

(classmethod) make_response

(classmethod) request_context

(classmethod) auto_find_instance_path

(setupmethod) add_template_test

(setupmethod) after_request

(setupmethod) teardown_request

(classmethod) trap_http_exception

方法类型介绍:

  • 成员方法:类方法中第一个参数是self的为类成员方法。
  • classmethod 类方法中第一个参数是cls(类对象)的方法
  • property 类变量的只读方法: 使用了装饰器@property的方法
  • staticmethod: 使用了装饰器@staticmethod的静态方法。静态方法和类方法相似,区别是静态方法不关注对象和对象内部属性,静态方法不强制要求参数。
  • setupmethod

@classmethod means: when this method is called, we pass the class as the first argument instead of the instance of that class (as we normally do with methods). This means you can use the class and its properties inside that method rather than a particular instance.
@staticmethod means: when this method is called, we don't pass an instance of the class to it (as we normally do with methods). This means you can put a function inside a class but you can't access the instance of that class (this is useful when your method does not use the instance).