大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。
Jetbrains全系列IDE稳定放心使用
useragent模块
- UserAgent(ua:str)
# ua测试字符串
ua = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.101 Safari/537.36'
# 实例化
user_agent = useragents.UserAgent(ua)
.platform -> windows
.version -> 60.0.3112.101
.string -> Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.101 Safari/537.36
.language -> None
.brower -> chrome
urls模块
routing模块
wsgi模块
get_current_url(environ, root_only=False, strip_querystring=False,host_only=False, trusted_hosts=None)host_is_trusted(hostname, trusted_list)-> 暂时不清楚get_host(environ, trusted_hosts=None)->传入env,获取hostget_content_length(environ)get_input_stream(environ, safe_fallback=True, max_content_length=None)get_input_stream(environ, safe_fallback=True, max_content_length=None)-> 从WSGI环境返回输入流,并以最明智的方式进行包装。 在大多数情况下,返回的流不是原始的WSGI流,但是在不考虑内容长度的情况下可以安全地读取流。(暂时不清楚)get_query_string(environ)get_path_info(environ, charset='utf-8', errors='replace')->URL路径除了起始部分后的剩余部分,用于找到相应的应用程序对象,如果请求的路径就是根路径,这个值为空字符串从WSGI环境返回“PATH_INFO”,并正确解码它。 这也关注了在Python 3环境下的WSGI解码舞蹈。 如果charset设置为None,则返回一个bytestring。(暂时不清楚)get_script_name(environ, charset='utf-8', errors='replace')pop_path_info(environ, charset='utf-8', errors='replace')-> 删除并返回“PATH_INFO”的下一个段,将其推送到“SCRIPT_NAME”上。 如果PATH_INFO上没有任何内容,则返回None。 如果charset设置为None,则返回一个bytestring。 如果有空段('/ foo // bar)这些被忽略,但被正确地推到“SCRIPT_NAME”peek_path_info(environ, charset='utf-8', errors='replace')-> 如果没有,返回“PATH_INFO”或“无”的下一个段。 工作原理如下:func:pop_path_info而不修改环境extract_path_info(environ_or_baseurl, path_or_url, charset='utf-8', errors='replace', collapse_http_schemes=True)-> 从给定的URL(或WSGI环境)和路径中提取路径信息。 返回的路径信息是一个unicode字符串,而不是一个适合WSGI环境的bytest。 这些URL也可能是IRI。 如果无法确定路径信息,则返回“None”class SharedDataMiddleware(object)->用于处理静态文件class DispatcherMiddleware(object)->组合多个app
application = DispatcherMiddleware(firstapp, {'/secondapp': secondapp, '/thirdapp': thirdapp})
run_simple('localhost', 5000, application, use_reloader=True, use_debugger=True)
wrappers模块
-
BaseRequest对象form属性,数据结构为werkzeug.datastructures.ImmutableMultiDict,可以通过parameter_storage_class来修改(如果表单顺序有要求,这可能是必需的)-
valules属性,把form表单和get参数组合起来放在一个字典里面,数据结构为CombinedMultiDict。例如:CombinedMultiDict([ImmutableMultiDict([('name', 'xiaoming')]), ImmutableMultiDict([('age', '12')])]) 取值: name = values.get('name') age = values.get('age) -
files属性,包括所有的上传文件。数据结构werkzeug.datastructures.MultiDict,键名为input标签的name属性,每个value代表一个真实文件,数据结构为werkzeug.datastructures.FileStorage,就像一个标准的Python文件对象,不过有一个单独的方法.save()用来将文件存放在本地。注意:客户端需使用POST/PUT/PATCH的其中一个方式,并且表单要设置enctype="multipart/form-data,否则会接收到空字典 cookies属性,一个字典,里面存放了cookies信息headers属性,数据结构werkzeug.datastructures.EnvironHeaders,从WSGI环境里面读出来的头信息,dict形式full_path属性,http://localhost:5000/form?namea=xiaoming->/form?namea=xiaomingscript_root属性,The root path of the script without the trailing slash.url属性,全路径base_url,基本路径http://localhost:5000/form?namea=xiaoming->http://localhost:5000/formurl_root-> 根路径http://localhost:5000/form?namea=xiaoming->http://localhost:5000/host_url-> host+协议http://localhost:5000/form?namea=xiaoming->http://localhost:5000/host-> localhost:5000query_stringget的查询数据http://localhost:5000/form?namea=xiaoming->b'namea=xiaoming'method请求方法GET/POSTaccess_route如果转发的头部存在,这是从客户端ip到最后一个代理服务器的所有ip地址的列表remote_addr-> 客户端IPremote_user->If the server supports user authentication, and the script is
protected, this attribute contains the username the user has
authenticated as.scheme-> 协议http/httpsis_xhr属性,用X-Requested-With来判断的,所以不一定可信environ一个wsgi和env对象,是一个字典
REQUEST_METHOD->GET|POSTSCRIPT_NAME->''PATH_INFO->/formQUERY_STRING->namea=xiaomingSERVER_NAME->127.0.0.1SERVER_PORT->5000HTTP_HOST->localhost:5000SERVER_PROTOCOL->HTTP/1.1wsgi.url_scheme->httpCONTENT_TYPE-> ”CONTENT_LENGTH->0HTTP_CONNECTION->closeHTTP_COOKIEHTTP_ACCEPT_LANGUAGE->zh-CN,zh;q=0.8HTTP_ACCEPT_ENCODING->gzip, deflate, brHTTP_DNT->1HTTP_ACCEPT->text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8HTTP_USER_AGENTHTTP_UPGRADE_INSECURE_REQUESTSHTTP_CACHE_CONTROL->max-age=0HTTP_HOST->localhost:5000REMOTE_PORT->50556REMOTE_ADDR->127.0.0.1SERVER_SOFTWARE->Werkzeug/0.12.2wsgi.version->1,0wsgi.url_scheme->httpswsgi.input->''wsgi.errorswsgi.multithread->Falsewsgi.multiprocess->Falsewsgi.run_once->False
BaseResponse对象
–set_cookie(self, key, value='', max_age=None, expires=None, path='/', domain=None, secure=False, httponly=False)-> 设置响应体的Cookies
–delete_cookie(self, key, path='/', domain=None)-> 删除cookie
utils模块
secure_filename(filename)-> 返回安全文件名escape(s,quote=None)-> 字符串转义unescape(s)-> 反转义redirect(location, code=302, Response=None)-> 重定向append_slash_redirect(environ, code=301)-> 给url的尾巴上添加/,以生成唯一的url。haonse.com -> haonse.com/
serving模块
security模块
pbkdf2_hex(data, salt, iterations=DEFAULT_PBKDF2_ITERATIONS,keylen=None, hashfunc=None)->类似 :func:pbkdf2_bin, but 返回一个 hex-encoded 字符串pbkdf2_bin(data, salt, iterations=DEFAULT_PBKDF2_ITERATIONS, keylen=None, hashfunc=None)-> pbkdf2算法生成密钥safe_str_cmp(a, b)– > 两个字符串比较gen_salt(length)-> 生成一个盐(随机字符串)generate_password_hash(password, method='pbkdf2:sha256', salt_length=8)-> 用指定的方法和盐的长度生成密码check_password_hash(pwhash, password)-> 验证上面的safe_join(directory, *pathnames)-> 生成一个安全的path
local模块
formparser模块
http模块
wsgi_to_bytes(data)-> 将data转成latin1bytes_to_wsgi-> 相反parse_cookie(header, charset='utf-8', errors='replace', cls=None):-> 把raw_cookies解析成一个字典dump_cookie(key, value='', max_age=None, expires=None, path='/', domain=None, secure=False, httponly=False, charset='utf-8', sync_expires=True, max_size=4093):-> 装成一个cookie
filesystem模块
get_filesystem_encoding-> 返回系统编码。注意:这与Python对文件系统编码的理解不同,不建议将此值用于Python的unicode API。(不知道这个函数是用来干什么的,用到了再看)
datastructures模块
exceptions模块
posixemulation模块
test模块
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/185009.html原文链接:https://javaforall.net
