You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
805 B
35 lines
805 B
from glob import escape
|
|
from flask import Flask,request,json
|
|
from markupsafe import escape
|
|
|
|
import os
|
|
import requests
|
|
|
|
app = Flask(__name__)
|
|
|
|
from flask import Flask
|
|
app = Flask(__name__)
|
|
|
|
@app.route('/')
|
|
def hello():
|
|
greet = '<h1>You should not be here!</h1>'
|
|
link = '<p><a href="https://www.google.com">Click me!</a></p>'
|
|
return greet + link
|
|
|
|
@app.route('/ping/<name>')
|
|
def ping(name):
|
|
personal = f'pinging, {name}'
|
|
|
|
response = os.system("ping -c 1 " + name)
|
|
if response == 0:
|
|
instruc = ' is up!'
|
|
address = 'http://%s' %name
|
|
r = requests.get(address)
|
|
status = r.status_code
|
|
status_string = str(status)
|
|
else:
|
|
instruc = ' is down!'
|
|
return personal + instruc + status_string
|
|
|
|
if __name__ == '__main__':
|
|
app.run(debug=True)
|