nginx配置文件nginx.conf中文详解

######Nginx配置文件nginx.conf中文详解#####

#定义Nginx运行的用户和用户组
user www www;

#nginx进程数,建议设置为等于CPU总核心数。
worker_processes 8;
 
#全局错误日志定义类型,[ debug | info | notice | warn | error | crit ]
error_log /usr/local/nginx/logs/error.log info;

#进程pid文件
pid /usr/local/nginx/logs/nginx.pid;
 继续阅读“nginx配置文件nginx.conf中文详解”

《Python进阶》读书笔记(2)

9.装饰器

既将函数传参给装饰器函数,在函数执行的上下文作某些通用操作。

记得要用@wraps复制函数名称(__name__),等等属性

使用举例:

from functools import wraps

def requires_auth(f):
    @wraps(f)
    def decorated(*args, **kwargs):
        auth = request.authorization
        if not auth or not check_auth(auth.username, auth.password):
            #若未登录,返回401
            authenticate()
        return f(*args, **kwargs)
    return decorated

继续阅读“《Python进阶》读书笔记(2)”