Browse Source

added json output

master
Domagoj Zecevic 3 years ago
parent
commit
63344a39f6
  1. 15
      ping_engine.py

15
ping_engine.py

@ -1,5 +1,5 @@
from glob import escape from glob import escape
from flask import Flask,request,json from flask import Flask,request,jsonify
from markupsafe import escape from markupsafe import escape
import os import os
@ -34,7 +34,9 @@ def ping(name):
ip_addr = request.remote_addr ip_addr = request.remote_addr
out = '%s - Unauthorized from IP: %s' %(now, ip_addr) out = '%s - Unauthorized from IP: %s' %(now, ip_addr)
print (out) print (out)
return now + instruc return jsonify(
time = now,
status = instruc)
@app.route('/http/<name>/') @app.route('/http/<name>/')
def http(name): def http(name):
@ -57,7 +59,9 @@ def http(name):
ip_addr = request.remote_addr ip_addr = request.remote_addr
out = '%s - Unauthorized from IP: %s' %(now, ip_addr) out = '%s - Unauthorized from IP: %s' %(now, ip_addr)
print (out) print (out)
return now + status_string return jsonify (
time = now,
status = status_string)
@app.route('/https/<name>/') @app.route('/https/<name>/')
def https(name): def https(name):
@ -80,7 +84,10 @@ def https(name):
ip_addr = request.remote_addr ip_addr = request.remote_addr
out = '%s - Unauthorized from IP: %s' %(now, ip_addr) out = '%s - Unauthorized from IP: %s' %(now, ip_addr)
print (out) print (out)
return now + status_string return jsonify (
time = now,
status = status_string)
if __name__ == '__main__': if __name__ == '__main__':
app.run(debug=True) app.run(debug=True)
Loading…
Cancel
Save