Created
September 22, 2016 21:55
-
-
Save homelinen/73c3af96059a7a3f3cec4d0f001bbdc4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# | |
# Requirements: | |
# Flask==0.11.1 | |
import ipaddress | |
from flask import Flask, request | |
app = Flask(__name__) | |
@app.route('/') | |
def entry(): | |
ip_network = ipaddress.ip_network('172.16.0.0/12') | |
ip_address = ipaddress.ip_address(request.remote_addr) | |
if ip_address in ip_network: | |
return "Welcome {}".format(ip_address) | |
else: | |
return "Forbidden {} not in Network {}".format(ip_address, ip_network) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment