Browse Source

🎈 perf: 停止跟踪部分文件,创建config文件

Pchen. 4 months ago
parent
commit
6d3c07f6ca

+ 5 - 0
.gitignore

@@ -0,0 +1,5 @@
+__pycache__/
+*.pyc
+*.pyo
+
+db_config.py

BIN
api/__pycache__/gitRouter.cpython-312.pyc


+ 3 - 3
api/gitRouter.py

@@ -1,6 +1,6 @@
 import os, json,hashlib
 from fastapi import APIRouter, BackgroundTasks
-
+from base_config import path, avatar_url
 
 from git import Repo
 
@@ -21,7 +21,7 @@ class CommitHash(BaseModel):
 
 def generate_repo_path(uuid, repo_url):
     repo_name = repo_url.split("/")[-1].replace(".git", "")
-    base_path = os.path.join("C:/Users/32965/repo", uuid)
+    base_path = os.path.join(path, uuid)
     return os.path.join(base_path, repo_name), repo_name
 
 
@@ -54,7 +54,7 @@ async def log(request: RequestBody):
     email = user.email
     # email = "gshn666@qq.com"
     email_md5 = hashlib.md5(email.encode(encoding='UTF-8')).hexdigest()
-    avatar = "https://cravatar.cn/avatar/"+email_md5+"?d=identicon"
+    avatar = avatar_url+email_md5+"?d=identicon"
     local_path, _ = generate_repo_path(request.uuid, request.repo_url)
     repo = get_repo(request.uuid, request.repo_url)
     if not repo:

+ 2 - 0
base_config.py

@@ -0,0 +1,2 @@
+path = "/www/gitnexus/"
+avatar_url = "https://cravatar.cn/avatar/"

+ 25 - 0
db_config_example.py

@@ -0,0 +1,25 @@
+TORTOISE_ORM = {
+    "connections": {
+        "default": {
+            "engine": "tortoise.backends.mysql",
+            "credentials": {
+                "host": "127.0.0.1",
+                "port": 3306,
+                "user": "gitnexus",
+                "password": "",
+                "database": "",
+                "minsize": 3,    # 最小连接数
+                "maxsize": 20,   # 最大连接数
+                "charset": "utf8mb4"
+            }
+        }
+    },
+    "apps": {
+        "models": {
+            "models": ["models.gitModels"],  # 包含模型文件
+            "default_connection": "default"
+        }
+    },
+    "use_tz": False,
+    "timezone": "Asia/Shanghai"
+}

BIN
models/__pycache__/__init__.cpython-312.pyc


BIN
models/__pycache__/gitModels.cpython-312.pyc