Skip to content

Instantly share code, notes, and snippets.

@skateinmars
Created March 21, 2018 09:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skateinmars/c66758c261071b428722ac45bb65d897 to your computer and use it in GitHub Desktop.
Save skateinmars/c66758c261071b428722ac45bb65d897 to your computer and use it in GitHub Desktop.
Example dockerfile with simplest possible python server
FROM gliderlabs/alpine:3.4
ENV PORT 80
RUN apk-install python
ADD . /app
WORKDIR /app
CMD python /app/server.py
EXPOSE 80
#!/usr/bin/python
# This file is only provided as an example on how to organize your services.
# Delete it when starting to implement your service code.
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
import os
PORT = int(os.environ['PORT'])
class Handler(BaseHTTPRequestHandler):
# Handler for the GET requests
def do_GET(self):
self.send_response(200)
self.end_headers()
self.wfile.write("Hello World!")
return
server = HTTPServer(('', PORT), Handler)
print 'Started HTTP server on port', PORT
server.serve_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment