在Python中从请求中提取IP [英] Extracting IP from request in Python

查看:409
本文介绍了在Python中从请求中提取IP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应该确定客户端IP的Pythonic HTTP服务器。我如何在Python中做到这一点?有什么方法可以获取请求标题并从中提取它?



PS:我使用WebPy。



 类示例:
def GET(self):
print web.ctx.ip

更多信息这里


I have a Pythonic HTTP server that is supposed to determine client's IP. How do I do that in Python? Is there any way to get the request headers and extract it from there?

PS: I'm using WebPy.

解决方案

Use web.ctx:

class example:
    def GET(self):
        print web.ctx.ip

More info here

这篇关于在Python中从请求中提取IP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆