代码拉取完成,页面将自动刷新
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)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。