From ff44ce6264ecc8c11c403523819800176f7dc854 Mon Sep 17 00:00:00 2001 From: mxr612 Date: Mon, 16 Jun 2025 05:27:45 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0IP=E5=9C=B0=E5=9D=80?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E5=8A=9F=E8=83=BD=E4=BB=A5=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=93=8D=E5=BA=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在RawResponse模型中新增ip_address字段 - 更新结果处理逻辑以记录用户的IP地址 --- app.py | 1 + database.py | 1 + 2 files changed, 2 insertions(+) diff --git a/app.py b/app.py index 73034a0..05de73d 100644 --- a/app.py +++ b/app.py @@ -87,6 +87,7 @@ async def result(request: Request, scale_id: str, db: Session = Depends(get_db)) db_response = RawResponse( scale_id=scale_id, user_agent=request.headers.get("user-agent", "Unknown"), + ip_address=request.client.host, response=dict(form_data) ) db.add(db_response) diff --git a/database.py b/database.py index 984934a..77038a0 100644 --- a/database.py +++ b/database.py @@ -18,6 +18,7 @@ class RawResponse(Base): id = Column(Integer, primary_key=True, index=True) scale_id = Column(String, index=True) user_agent = Column(String) + ip_address = Column(String) response = Column(JSON) created_at = Column(DateTime, default=datetime.now(UTC))