Flask:Python - 如何检查请求的IP地址

时间:2012-06-01 02:32:35

标签: python flask

  

可能重复:
  Get ip address of visitors using Python (specifically Flask micro-framework)

我正在用烧瓶创建REST api。我想仅允许来自一个(或更多个以后)IP地址的请求。如何在我的视图中检查IP地址?

2 个答案:

答案 0 :(得分:5)

Incoming Request Data获取标题并找到REMOTE_ADDR

答案 1 :(得分:1)

如果您使用的是谷歌应用引擎,则可以使用self.request.remote_addr

相关问题