-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM python:3.8 | ||
LABEL maintainer="Udacity" | ||
|
||
COPY . /app | ||
WORKDIR /app | ||
RUN pip install -r requirements.txt | ||
|
||
# command to run on container start | ||
CMD [ "python", "app.py" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from flask import Flask | ||
from flask import json | ||
import logging | ||
|
||
app = Flask(__name__) | ||
|
||
@app.route('/status') | ||
def healthcheck(): | ||
response = app.response_class( | ||
response=json.dumps({"result":"OK - healthy"}), | ||
status=200, | ||
mimetype='application/json' | ||
) | ||
|
||
app.logger.info('Status request successfull') | ||
return response | ||
|
||
@app.route('/metrics') | ||
def metrics(): | ||
response = app.response_class( | ||
response=json.dumps({"status":"success","code":0,"data":{"UserCount":140,"UserCountActive":23}}), | ||
status=200, | ||
mimetype='application/json' | ||
) | ||
|
||
app.logger.info('Metrics request successfull') | ||
return response | ||
|
||
@app.route("/") | ||
def hello(): | ||
app.logger.info('Main request successfull') | ||
|
||
return "Hello World!" | ||
|
||
if __name__ == "__main__": | ||
## stream logs to a file | ||
logging.basicConfig(filename='app.log',level=logging.DEBUG) | ||
|
||
app.run(host='0.0.0.0') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Flask==1.1.1 | ||
werkzeug==0.16.1 |
3 changes: 3 additions & 0 deletions
3
Lesson-3-Containerization/python-helloworld/test_with_pytest.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## Define a test that will always pass successfully | ||
def test_always_passes(): | ||
assert True |