Created
January 20, 2011 20:52
-
-
Save afandian/788639 to your computer and use it in GitHub Desktop.
Ping Server
This file contains 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
import web | |
import subprocess | |
urls = ( | |
'/ping/(.*)/', 'ping' | |
) | |
app = web.application(urls, globals()) | |
class ping: | |
def GET(self, ip): | |
result = subprocess.call(["ping", "-c", "1", ip]) | |
# return code zero means that ping worked | |
if result == 0: | |
return "ok" | |
else: | |
return "not ok" | |
if __name__ == "__main__": | |
app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You will need to install web.py from http://webpy.org/ (that's easy). Run this by doing:
then in your browser to go http://localhost:10000/ping/localhost/ (i.e. connect to server running on local machine and attempt to ping self).
Where the number is the port you want to run it on.
To go with https://gist.github.com/788658.