python获取用户登录ip

Posted on 2023-03-14 13:20  o0o0o9  阅读(29)  评论(0编辑  收藏  举报
import socket

def ip_check():
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    s.connect(('8.8.8.8', 80))
    ip = s.getsockname()[0]
    s.close()
    ip_list=['192.168.1.101','192.168.1.102']
    print(ip in ip_list)
    if ip in ip_list:
        yhls_search()
    else:
        pywebio.output.put_text('对不起您没有授权,请联系...')

 

Copyright © 2024 o0o0o9
Powered by .NET 9.0 on Kubernetes