-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapplication.py
More file actions
29 lines (24 loc) · 763 Bytes
/
application.py
File metadata and controls
29 lines (24 loc) · 763 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import os
from flask import Flask, request, make_response#render_template
import hashlib
import json
application = Flask(__name__)
application.debug = True
@application.route('/')
def index():
return make_response(open('templates/index.html').read())
@application.route('/hash')
def get_hash():
m = hashlib.md5()
m.update(request.remote_addr)
hashed_ip = m.hexdigest()
return make_response(json.dumps({'hash' : hashed_ip, 'ipAddress' : request.remote_addr}))
@application.route('/customhash')
def post_hash():
ip_address = request.args.get('ipAddress');
m = hashlib.md5()
m.update(ip_address)
hashed_ip = m.hexdigest()
return make_response(json.dumps({'hash' : hashed_ip}))
if __name__ == "__main__":
application.run(host='0.0.0.0', debug=True)