Add basic server image

This commit is contained in:
Pierre HUBERT 2024-09-20 14:41:10 +02:00
parent 0e8691c765
commit 7e5b1007a3
3 changed files with 23 additions and 0 deletions

4
basic_server/Dockerfile Normal file
View File

@ -0,0 +1,4 @@
FROM python:3-slim
COPY server.py /server.py
EXPOSE 80
CMD ["python3", "/server.py"]

2
basic_server/build.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/sh
sudo docker build -t pierre42100/gns3-appliance-basic-server .

17
basic_server/server.py Normal file
View File

@ -0,0 +1,17 @@
from http.server import BaseHTTPRequestHandler, HTTPServer
PORT = 80
print(f"Will listen on port {PORT}")
class handler(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header('Content-type','text/html')
self.end_headers()
message = "Hello, World! Here is simple HTTP response..."
self.wfile.write(bytes(message, "utf8"))
with HTTPServer(('', PORT), handler) as server:
server.serve_forever()