mirror of
https://github.com/YunoHost/example_ynh.git
synced 2024-09-03 20:06:13 +02:00
Create myServer.py
This commit is contained in:
parent
c6ed19e2ef
commit
5748f1b182
1 changed files with 27 additions and 0 deletions
27
myServer.py
Normal file
27
myServer.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/python
|
||||
from BaseHTTPServer import BaseHTTPRequestHandler,HTTPServer
|
||||
|
||||
PORT_NUMBER = 8080
|
||||
|
||||
#This class will handles any incoming request from
|
||||
#the browser
|
||||
class myHandler(BaseHTTPRequestHandler):
|
||||
|
||||
#Handler for the GET requests
|
||||
def do_GET(self):
|
||||
self.send_response(200)
|
||||
self.send_header('Content-type','text/html')
|
||||
self.end_headers()
|
||||
# Send the html message
|
||||
self.wfile.write("Hello World !")
|
||||
print self.path
|
||||
return
|
||||
try:
|
||||
#Create a web server and define the handler to manage the
|
||||
#incoming request
|
||||
server = HTTPServer(('', PORT_NUMBER), myHandler)
|
||||
print 'Started httpserver on port ' , PORT_NUMBER
|
||||
|
||||
#Wait forever for incoming htto requests
|
||||
server.serve_forever()
|
||||
|
Loading…
Add table
Reference in a new issue