aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeodarZ <neodarz@neodarz.ovh>2016-09-23 16:19:19 +0200
committerNeodarZ <neodarz@neodarz.ovh>2016-09-23 16:19:19 +0200
commit6f69e7c3d06cacc654afa71c721c171421ed005d (patch)
tree5aec735e2fd59b2a758d01525118e31e0f4239eb
downloadweb_checker-6f69e7c3d06cacc654afa71c721c171421ed005d.tar.xz
web_checker-6f69e7c3d06cacc654afa71c721c171421ed005d.zip
First commit
-rwxr-xr-xindex.py36
-rwxr-xr-xserver.py14
2 files changed, 50 insertions, 0 deletions
diff --git a/index.py b/index.py
new file mode 100755
index 0000000..cf8dd15
--- /dev/null
+++ b/index.py
@@ -0,0 +1,36 @@
+#!/usr/bin/python3
+# -*- coding: utf-8 -*
+
+import cgi
+import http.client
+import sys
+
+from socket import gethostbyname, gaierror
+
+form = cgi.FieldStorage()
+print("Content-type: text/html; charset=utf-8\n")
+
+
+name = "Website"
+urls = ["neodarz.ovh","plex.neodarz.ovh","git.neodarz.ovh"]
+
+for url in urls:
+ try:
+ c = http.client.HTTPConnection(url)
+ c.request("HEAD", '')
+ status = str(c.getresponse().status)
+ except gaierror:
+ status = "Name or service unknow !"
+
+
+
+ html = """<!DOCTYPE html>
+ <head>
+ <title>Mon programme</title>
+ </head>
+ <body>
+ <p><a href='""" + url + """'> """ + url + """</a> ->""" + status + """</p>
+ </body>
+ </html>"""
+
+ print(html)
diff --git a/server.py b/server.py
new file mode 100755
index 0000000..89b86dc
--- /dev/null
+++ b/server.py
@@ -0,0 +1,14 @@
+#!/usr/bin/python3
+
+import http.server
+
+PORT = 8889
+server_address = ("", PORT)
+
+server = http.server.HTTPServer
+handler = http.server.CGIHTTPRequestHandler
+handler.cgi_directories = ["/"]
+print("Serveur actif sur le port : ", PORT)
+
+httpd = server(server_address, handler)
+httpd.serve_forever()