Skip to content

Commit

Permalink
Add Chapter 2 Lecture 7 files
Browse files Browse the repository at this point in the history
  • Loading branch information
timhberry committed Jul 25, 2019
1 parent 6989543 commit cec84d9
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Chapter_Two/Lecture_7_Lab/myapp/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM python:3.5

COPY . /app
WORKDIR /app

RUN pip install -r requirements.txt

CMD ["python", "-u", "server.py"]
22 changes: 22 additions & 0 deletions Chapter_Two/Lecture_7_Lab/myapp/myapp-deployment.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
piVersion: apps/v1
kind: Deployment
metadata:
name: myapp-deployment
labels:
app: myapp
spec:
replicas: 3
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
spec:
containers:
- name: myapp
image: gcr.io/tim-acloud-guru/myapp:blue
ports:
- containerPort: 8888

13 changes: 13 additions & 0 deletions Chapter_Two/Lecture_7_Lab/myapp/myapp-service.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: myapp-service
spec:
selector:
app: myapp
ports:
- protocol: TCP
port: 80
targetPort: 8888
type: LoadBalancer

2 changes: 2 additions & 0 deletions Chapter_Two/Lecture_7_Lab/myapp/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tornado

23 changes: 23 additions & 0 deletions Chapter_Two/Lecture_7_Lab/myapp/server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import tornado.ioloop
import tornado.web


class MainHandler(tornado.web.RequestHandler):
def get(self):
title = "Hello, World!"
bgcolor = "dodgerblue"
self.render("template.html", title=title, bgcolor=bgcolor)
print(self.request)


def make_app():
return tornado.web.Application([
(r"/", MainHandler),
])


if __name__ == "__main__":
app = make_app()
app.listen(8888)
tornado.ioloop.IOLoop.current().start()

13 changes: 13 additions & 0 deletions Chapter_Two/Lecture_7_Lab/myapp/template.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<title>{{ title }}</title>
</head>
<body bgcolor="{{ bgcolor }}">
<h1 style="color:white;font-family:Arial, Helvetica, sans-serif;text-align: center">
<strong>
{{ title }}
</strong>
</h1>
</body>
</html>

0 comments on commit cec84d9

Please sign in to comment.