Flask 类

参数
Flask初始化参数
import_name应用包的名字
static_path=None
static_url_path=Nonecan be used to specify a different path for the static files on the web. Defaults to the name of the static_folder folder.
static_folder=’static’更改静态文件夹的路径,默认是根目录下的static
template_folder=’templates’更改模板夹的路径,默认是根目录下的templates
instance_path=None如果instance_relative_config=True指定config文件的路径
instance_relative_config=False如果为true,config文件需要放在instance_path=None,默认放在主文件同一个目录
root_path=NoneFlask by default will automatically calculate the path to the root of the application. In certain situations this cannot be achieved (for instance if the package is a Python 3 namespace package) and needs to be manually defined.
Flask.route(rule, **options)
rule路由路径
endpointthe endpoint for the registered URL rule. Flask itself assumes the name of the view function as endpoint
optionsthe options to be forwarded to the underlying Rule object. A change to Werkzeug is handling of method options. methods is a list of methods this rule should be limited to (GET, POST etc.). By default a rule just listens for GET (and implicitly HEAD). Starting with Flask 0.6, OPTIONS is implicitly added and handled by the standard request handling.
Flask.run(host=None, port=None, debug=None, **options)
host默认是127.0.0.1,改成0.0.0.0之后可以在局域网内访问
port端口
debug默认False
optionsthe options to be forwarded to the underlying Werkzeug server.

对象方法

方法描述修饰函数参考
add_template_filter(*args,?**kwargs)注册特定的模板过滤template_filter()https://www.cnblogs.com/why957/p/9119443.html
add_template_global(*args, **kwargs)注册特定的模板全局方法template_global(*args, **kwargs)
add_template_test(*args, **kwargs)注册特定的模板测试template_test()
add_url_rule(*args, **kwargs)创建路由规则route()http://docs.jinkan.org/docs/flask/api.html#url-route-registrations
after_request(*args, **kwargs)注册一个方法,在每次请求后执行after_request(*args, **kwargs)
after_request_funcs = None查看已注册的请求后方法
app_context()
app_ctx_globals_class
auto_find_instance_path()
before_first_request(*args, **kwargs)注册一个方法,在当前应用实例第一次请求前执行
before_first_request_funcs = None查看已注册的第一请求前方法
before_request(*args, **kwargs)注册一个方法,在每次请求前执行before_request(*args, **kwargs)https://blog.csdn.net/kwsy2008/article/details/53005264
before_request_funcs = None查看已注册的请求前方法
blueprints = None查看所有的蓝图
config = None查看所有的配置
context_processor(*args, **kwargs)
create_global_jinja_loader()
create_jinja_environment()
create_url_adapter(request)
debug设置debug
debug_log_format设置debug的警告模式
default_config默认的配置
dispatch_request()
do_teardown_appcontext(exc=None)
do_teardown_request(exc=None)
enable_modules = True开启过期模块的支持
endpoint(*args, **kwargs)endpoint(*args, **kwargs)
error_handler_spec = None错误状态记录
errorhandler(*args, **kwargs)错误状态码处理errorhandler(*args, **kwargs)
extensions = None
full_dispatch_request()
get_send_file_max_age(filename)
got_first_request
handle_exception(e)
handle_http_exception(e)
handle_url_build_error(error, endpoint, values)
handle_user_exception(e)
has_static_folder是否有静态文件夹
inject_url_defaults(endpoint, values)
instance_path = None
jinja_env
jinja_loader
jinja_options
json_decoder
json_encoder
log_exception(exc_info)
logger
logger_name
make_config(instance_relative=False)
make_default_options_response()
make_null_session()
make_response(rv)
name
open_instance_resource(resource, mode=‘rb’)
open_resource(resource, mode=‘rb’)
open_session(request)
permanent_session_lifetime
preprocess_request()
preserve_context_on_exception
process_response(response)
propagate_exceptions
register_blueprint(*args, **kwargs)注册一个蓝图
register_error_handler(code_or_exception, f)注册一个错误处理
register_module(module, **options)注册一个模块
request_class
request_context(environ)
response_class
run(host=None, port=None, debug=None, **options)
save_session(session, response)
secret_key
select_jinja_autoescape(filename)
send_static_file(filename)
session_cookie_name
session_interface
should_ignore_error(error)
teardown_appcontext(*args, **kwargs)
teardown_appcontext_funcs = None
teardown_request(*args, **kwargs)
teardown_request_funcs = None
template_context_processors = None
test_client(use_cookies=True)
test_client_class = None
test_request_context(*args, **kwargs)
testing
trap_http_exception(e)
update_template_context(context)
url_build_error_handlers = None
url_default_functions = None
url_defaults(*args, **kwargs)
url_map = None
url_rule_class
url_value_preprocessor(*args, **kwargs)
url_value_preprocessors = None
use_x_sendfile
view_functions = None
wsgi_app(environ, start_response)
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值