-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
f4b83e1
commit df74dde
Showing
10 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
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,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 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,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; | ||
} |
Binary file not shown.
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,30 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>Monitoring & Logging</title> | ||
<meta | ||
content="width=device-width, initial-scale=1, maximum-scale=1" | ||
name="viewport" | ||
/> | ||
<link rel="stylesheet" type="text/css" href="../static/main.css"/> | ||
</head> | ||
|
||
<body> | ||
<div class = "container"> | ||
<div class="header box">Logging Center</div> | ||
<div class="content box"> | ||
{% if log %} | ||
<p>{{ log }}</p> | ||
{% endif %} | ||
<form action="/"> | ||
<input type="submit" name="log_button" value="info"> | ||
<input type="submit" name="log_button" value="warning"> | ||
<input type="submit" name="log_button" value="error"> | ||
<input type="submit" name="log_button" value="critical"> | ||
</form> | ||
</div> | ||
<div class="footer box">Copyright 2020 Udacious Student</div> | ||
</div> | ||
</body> | ||
</html> |
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,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 | ||
) |