feat: 增加IP地址记录功能以保存用户响应
- 在RawResponse模型中新增ip_address字段 - 更新结果处理逻辑以记录用户的IP地址
This commit is contained in:
parent
7989c8ed4e
commit
ff44ce6264
1
app.py
1
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)
|
||||
|
@ -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))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user