mirror of
https://github.com/fastapi-admin/fastapi-admin.git
synced 2025-08-17 04:40:13 +08:00
add Visitor in example
This commit is contained in:
12
examples/common.py
Normal file
12
examples/common.py
Normal file
@ -0,0 +1,12 @@
|
||||
from starlette.requests import Request
|
||||
|
||||
|
||||
def get_client_ip(request: Request):
|
||||
"""
|
||||
:param request:
|
||||
:return:
|
||||
"""
|
||||
forwarded = request.headers.get("X-Forwarded-For")
|
||||
if forwarded:
|
||||
return forwarded.split(",")[0]
|
||||
return request.client.host
|
Reference in New Issue
Block a user