From b8b7f5c7684ff521536d53d89823753601b6c881 Mon Sep 17 00:00:00 2001 From: WangZhanze Date: Mon, 20 Jan 2025 15:39:23 +0800 Subject: [PATCH] toml config --- cookiecutter.json | 1 - {{cookiecutter.project_slug}}/.gitignore | 1 + {{cookiecutter.project_slug}}/app/core/config.py | 6 +++--- {{cookiecutter.project_slug}}/config.toml.template | 5 +++-- {{cookiecutter.project_slug}}/tests/conftest.py | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/cookiecutter.json b/cookiecutter.json index 41e8d10..fdf88ca 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -4,6 +4,5 @@ "project_short_description": "Python Boilerplate contains all the boilerplate you need to create a Python package.", "email": "leolswq@163.com", "github_username": "leo03wzz", - "secret_key": "super_secret", "version": "0.1.0" } diff --git a/{{cookiecutter.project_slug}}/.gitignore b/{{cookiecutter.project_slug}}/.gitignore index 44bbb13..4bfa541 100644 --- a/{{cookiecutter.project_slug}}/.gitignore +++ b/{{cookiecutter.project_slug}}/.gitignore @@ -159,3 +159,4 @@ cython_debug/ # option (not recommended) you can uncomment the following to ignore the entire idea folder. .idea/ .vscode/ +config.toml diff --git a/{{cookiecutter.project_slug}}/app/core/config.py b/{{cookiecutter.project_slug}}/app/core/config.py index 02d6bec..17652cf 100644 --- a/{{cookiecutter.project_slug}}/app/core/config.py +++ b/{{cookiecutter.project_slug}}/app/core/config.py @@ -12,9 +12,9 @@ class Settings(BaseSettings): """Application settings.""" # 应用配置 - APP_NAME: str = "{{ cookiecutter.project_name }}" - DEBUG: bool = False - SECRET_KEY: str = "{{ cookiecutter.secret_key }}" + APP_NAME: str + DEBUG: bool + SECRET_KEY: str # 路径配置 BASE_DIR: Path = Path(__file__).parent.parent.parent diff --git a/{{cookiecutter.project_slug}}/config.toml.template b/{{cookiecutter.project_slug}}/config.toml.template index 45e9403..1743b24 100644 --- a/{{cookiecutter.project_slug}}/config.toml.template +++ b/{{cookiecutter.project_slug}}/config.toml.template @@ -1,5 +1,6 @@ # Application configuration -app_name = "{{ cookiecutter.project_name }}" -debug = false +APP_NAME = "{{ cookiecutter.project_name }}" +DEBUG = false +SECRET_KEY = "your_secret_key" # Add your custom configuration here \ No newline at end of file diff --git a/{{cookiecutter.project_slug}}/tests/conftest.py b/{{cookiecutter.project_slug}}/tests/conftest.py index a2dced8..7604335 100644 --- a/{{cookiecutter.project_slug}}/tests/conftest.py +++ b/{{cookiecutter.project_slug}}/tests/conftest.py @@ -3,5 +3,5 @@ import sys from pathlib import Path # Add the src directory to the Python path -src_path = Path(__file__).parent.parent / "app" +src_path = Path(__file__).parent.parent sys.path.insert(0, str(src_path))