1 Star 0 Fork 0

刘智雄/ carAnalysisBackEnd

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
setting.py 4.42 KB
一键复制 编辑 原始数据 按行查看 历史
刘智雄 提交于 2022-02-22 10:46 . gitignore
import secrets
from typing import List
from pydantic import BaseSettings, AnyHttpUrl
import os
class Settings(BaseSettings):
BASEDIR = os.path.abspath(os.path.dirname(__file__))
LOG_PATH = os.path.join(BASEDIR, 'logs')
BACKEND_CORS_ORIGINS: List = ['http://localhost:8080']
# 全局资源路径
# GOBAL_RESOURCE = r"/Users/macmini/Documents/fastapi_project/car-analysis-back-end/source/"
# GOBAL_RESOURCE = r"/www/wwwroot/car_infomation_back_end/source/"
GOBAL_RESOURCE = r"E:\毕业设计\fastApiProject\source\\"
# 默认管理员账号密码等信息
ADMIN_USERNAME = 'admin'
ADMIN_PASSWORD = '123456'
ADMIN_NICKNAME = 'admin'
ADMIN_EMAIL = '1104440778@qq.com'
# 数据库账号密码
DB_HOST = '42.193.254.225'
# DB_HOST = 'mysql'
DB_PORT = 3306
DB_USER = 'cardata'
DB_PASSWORD = '123456'
DB_NAME = 'cardata'
# DB_PASSWORD = ''
DATABASE_URI = f'mysql+pymysql://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{DB_PORT}'
SQLALCHEMY_DATABASE_URI: str = f'mysql+aiomysql://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{DB_PORT}/FastAPIVueBlog'
MYSQL_DATABASE_URI: str = f'mysql://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{DB_PORT}/{DB_NAME}'
SECRET_KEY: str = secrets.token_urlsafe(32)
# 12 hours
ACCESS_TOKEN_EXPIRE_MINUTES: int = 60 * 12
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'simple': {
'format': '[%(asctime)s] %(levelname)s %(message)s',
'datefmt': '%Y-%m-%d %H:%M:%S'
},
'standard': {
'format': '[%(asctime)s] %(levelname)s [%(name)s.%(funcName)s:%(lineno)d] %(message)s',
'datefmt': '%Y-%m-%d %H:%M:%S'
},
},
'handlers': {
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'standard'
},
'logfile': {
'level': 'INFO',
'class': 'logging.handlers.RotatingFileHandler',
'filename': os.path.join(BASEDIR, 'logs', 'debug.log'),
'maxBytes': 1024 * 1024 * 5, # 5 MB
'backupCount': 7,
'formatter': 'standard'
},
'db_logfile': {
'level': 'INFO',
'class': 'logging.handlers.RotatingFileHandler',
'filename': os.path.join(LOG_PATH, 'db.log'),
'maxBytes': 1024 * 1024 * 5, # 5 MB
'backupCount': 7,
'formatter': 'standard'
},
'run': {
'level': 'INFO',
'class': 'logging.handlers.RotatingFileHandler',
'filename': os.path.join(LOG_PATH, 'run.log'),
'maxBytes': 1024 * 1024 * 5, # 5 MB
'backupCount': 7,
'formatter': 'standard'
},
'error': {
'level': 'INFO',
'class': 'logging.handlers.RotatingFileHandler',
'filename': os.path.join(LOG_PATH, 'error.log'),
'maxBytes': 1024 * 1024 * 5, # 5 MB
'backupCount': 7,
'formatter': 'standard'
},
'test': {
'level': 'DEBUG',
'class': 'logging.handlers.RotatingFileHandler',
'filename': os.path.join(LOG_PATH, 'test.log'),
'maxBytes': 1024 * 1024 * 5, # 5 MB
'backupCount': 7,
'formatter': 'standard'
},
},
'loggers': {
'fastapi': {
'handlers': ['run'],
'level': 'DEBUG',
'propagate': False
},
'uvicorn.access': {
'handlers': ['run'],
'level': 'INFO',
'propagate': False
},
'uvicorn.error': {
'handlers': ['error'],
'level': 'INFO',
'propagate': False
},
'test': {
'handlers': ['logfile'],
'level': 'DEBUG',
'propagate': True,
},
'database': {
'handlers': ['db_logfile'],
'level': 'DEBUG',
'propagate': False,
},
},
}
settings = Settings()
# if not os.path.exists(settings.LOG_PATH):
# os.makedirs(settings.LOG_PATH)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/liu_zhi_xiong258/car-analysis-back-end.git
git@gitee.com:liu_zhi_xiong258/car-analysis-back-end.git
liu_zhi_xiong258
car-analysis-back-end
carAnalysisBackEnd
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385