diff --git a/FlaskExercise/.DS_Store b/FlaskExercise/.DS_Store new file mode 100644 index 0000000..3e329c3 Binary files /dev/null and b/FlaskExercise/.DS_Store differ diff --git a/FlaskExercise/__init__.py b/FlaskExercise/__init__.py new file mode 100644 index 0000000..cdb33ac --- /dev/null +++ b/FlaskExercise/__init__.py @@ -0,0 +1,12 @@ +import logging +from flask import Flask + +app = Flask(__name__) +wsgi_app = app.wsgi_app +# TODO: Set the app's logger level to "warning" +# and any other necessary changes +app.logger.setLevel(logging.WARNING) +streamHandler = logging.StreamHandler() +streamHandler.setLevel(logging.WARNING) +app.logger.addHandler(streamHandler) +import FlaskExercise.views \ No newline at end of file diff --git a/FlaskExercise/__pycache__/__init__.cpython-310.pyc b/FlaskExercise/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..883ee77 Binary files /dev/null and b/FlaskExercise/__pycache__/__init__.cpython-310.pyc differ diff --git a/FlaskExercise/__pycache__/__init__.cpython-39.pyc b/FlaskExercise/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..7945fae Binary files /dev/null and b/FlaskExercise/__pycache__/__init__.cpython-39.pyc differ diff --git a/FlaskExercise/__pycache__/views.cpython-310.pyc b/FlaskExercise/__pycache__/views.cpython-310.pyc new file mode 100644 index 0000000..bba677d Binary files /dev/null and b/FlaskExercise/__pycache__/views.cpython-310.pyc differ diff --git a/FlaskExercise/static/.DS_Store b/FlaskExercise/static/.DS_Store new file mode 100644 index 0000000..2b7e048 Binary files /dev/null and b/FlaskExercise/static/.DS_Store differ diff --git a/FlaskExercise/static/main.css b/FlaskExercise/static/main.css new file mode 100644 index 0000000..0b0db17 --- /dev/null +++ b/FlaskExercise/static/main.css @@ -0,0 +1,26 @@ +html { + font-family: OpenSans, sans-serif; + color: #fff; +} +body { + background: #02B3E4; +} +.container { + display:grid; + grid-gap: 20px; + grid-template-areas: + "hd hd hd" + "main main main" + "ft ft ft"; + text-align: center; +} +.header { + grid-area: hd; + font-size: 32px; +} +.footer { + grid-area: ft; +} +.content { + grid-area: main; +} \ No newline at end of file diff --git a/FlaskExercise/templates/.DS_Store b/FlaskExercise/templates/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/FlaskExercise/templates/.DS_Store differ diff --git a/FlaskExercise/templates/index.html b/FlaskExercise/templates/index.html new file mode 100644 index 0000000..ebd21cf --- /dev/null +++ b/FlaskExercise/templates/index.html @@ -0,0 +1,30 @@ + + + + + Monitoring & Logging + + + + + +
+
Logging Center
+
+ {% if log %} +

{{ log }}

+ {% endif %} +
+ + + + +
+
+ +
+ + \ No newline at end of file diff --git a/FlaskExercise/views.py b/FlaskExercise/views.py new file mode 100644 index 0000000..90070a9 --- /dev/null +++ b/FlaskExercise/views.py @@ -0,0 +1,22 @@ +from flask import flash, render_template, redirect, request +from FlaskExercise import app + + +@app.route('/') +def home(): + log = request.values.get('log_button') + # TODO: Appropriately log the different button presses + # with the appropriate log level. + if log: + if log == 'info': + app.logger.info('No issue.') + elif log == 'warning': + app.logger.warning('Warning occurred.') + elif log == 'error': + app.logger.error('Error occurred.') + elif log == 'critical': + app.logger.critical('Critical error occurred.') # noqa: E501 + return render_template( + 'index.html', + log=log + )