Skip to content

Commit 165126b

Browse files
Adding alternate flask application
1 parent 3a26f62 commit 165126b

File tree

7 files changed

+94
-0
lines changed

7 files changed

+94
-0
lines changed

flask-cz/static/blue.jpg

79.8 KB
Loading

flask-cz/static/green.png

182 KB
Loading

flask-cz/web/build_test

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM python:3.8-slim-buster
2+
3+
ENV VERSION=AppV1
4+
5+
COPY . .
6+
7+
WORKDIR /web
8+
9+
ENV FLASK_APP=simple-bg-server.py
10+
11+
RUN pip3 install -r requirements.txt
12+
13+
CMD ["tail", "-f", "/dev/null"]

flask-cz/web/build_v1

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM python:3.8-slim-buster
2+
3+
ENV VERSION=AppV1
4+
5+
COPY ./ /
6+
7+
WORKDIR /web
8+
9+
ENV FLASK_APP=simple-bg-server.py
10+
11+
RUN pip3 install -r requirements.txt
12+
13+
ENV FLASK_APP=simple-bg-server.py
14+
15+
CMD [ "python3", "-m" , "flask", "run", "--host=0.0.0.0"]

flask-cz/web/build_v2

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM python:3.8-slim-buster
2+
3+
ENV VERSION=AppV2
4+
5+
COPY . /
6+
7+
WORKDIR /web
8+
9+
RUN pip3 install -r requirements.txt
10+
11+
COPY . .
12+
13+
CMD [ "python3", "-m" , "flask", "run", "--host=0.0.0.0"]

flask-cz/web/requirements.txt

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
certifi==2022.9.24
2+
charset-normalizer==2.1.1
3+
click==8.1.3
4+
Flask==2.2.2
5+
idna==3.4
6+
importlib-metadata==5.0.0
7+
itsdangerous==2.1.2
8+
Jinja2==3.1.2
9+
MarkupSafe==2.1.1
10+
requests==2.28.1
11+
typing_extensions==4.3.0
12+
urllib3==1.26.12
13+
Werkzeug==2.2.2
14+
zipp==3.8.1

flask-cz/web/simple-bg-server.py

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import json, os
2+
from flask import Flask
3+
from queue import Queue
4+
5+
6+
app = Flask(__name__)
7+
hits = []
8+
hits_q = Queue(maxsize = 6 )
9+
version = os.environ.get('VERSION')
10+
11+
def append_version(curr_version):
12+
if hits_q.full():
13+
hits_q.get()
14+
15+
hits_q.put(curr_version)
16+
17+
@app.route("/")
18+
def hello_world():
19+
return "<p>Hello, World!</p>"
20+
21+
@app.route("/demo")
22+
def hello_demo():
23+
return "<h1>Hello, Kube-Con</h1>"
24+
25+
26+
@app.route("/version")
27+
def return_version():
28+
append_version(version)
29+
return f"<p>{version}<p>"
30+
31+
@app.route("/hits")
32+
def print_hits():
33+
hits = list(hits_q.queue)
34+
jsonStr= json.dumps(hits)
35+
return jsonStr
36+
37+
if __name__ == '__main__':
38+
app.run(debug=True, port='8000')
39+

0 commit comments

Comments
 (0)