import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
print(BASE_DIR) USER_HOME = "%s/home" % BASE_DIR
LOG_DIR = "%s/log" % BASE_DIR
LOG_LEVEL = "DEBUG" ACCOUNT_FILE = "%s/conf/accounts.cfg" % BASE_DIR HOST = "0.0.0.0"
PORT = 9999
还有一种,如下:
import os,sys #程序主目录文件
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
#添加环境变量
sys.path.insert(0,BASE_DIR)
# print(BASE_DIR)
#数据库目录
DATABASE = os.path.join(BASE_DIR,"database")
# print(DATABASE)
#用户属主目录
HOME_PATH = os.path.join(BASE_DIR,"home") #用户字典
USERS_PWD = {"alex":"123456","lzl":"8888","eric":"6666"} #磁盘配额 10M
LIMIT_SIZE = 10240000 #ftp服务端口
IP_PORT = ("0.0.0.0",9999)