-
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
dda7bfd
commit f4b83e1
Showing
3 changed files
with
29 additions
and
44 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 |
---|---|---|
@@ -1,8 +1,12 @@ | ||
""" | ||
The flask application package. | ||
""" | ||
|
||
import logging | ||
from flask import Flask | ||
app = Flask(__name__) | ||
|
||
import FlaskTemplate.views | ||
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 |
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 |
---|---|---|
@@ -1,37 +1,22 @@ | ||
""" | ||
Routes and views for the flask application. | ||
""" | ||
from flask import flash, render_template, redirect, request | ||
from FlaskExercise import app | ||
|
||
from datetime import datetime | ||
from flask import render_template | ||
from FlaskTemplate import app | ||
|
||
@app.route('/') | ||
@app.route('/home') | ||
def home(): | ||
"""Renders the home page.""" | ||
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', | ||
title='Home Page', | ||
year=datetime.now().year, | ||
) | ||
|
||
@app.route('/contact') | ||
def contact(): | ||
"""Renders the contact page.""" | ||
return render_template( | ||
'contact.html', | ||
title='Contact', | ||
year=datetime.now().year, | ||
message='Your contact page.' | ||
) | ||
|
||
@app.route('/about') | ||
def about(): | ||
"""Renders the about page.""" | ||
return render_template( | ||
'about.html', | ||
title='About', | ||
year=datetime.now().year, | ||
message='Your application description page.' | ||
log=log | ||
) |
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 |
---|---|---|
@@ -1,14 +1,10 @@ | ||
""" | ||
This script runs the FlaskTemplate application using a development server. | ||
""" | ||
|
||
from os import environ | ||
from FlaskTemplate import app | ||
from FlaskExercise import app | ||
|
||
if __name__ == '__main__': | ||
HOST = environ.get('SERVER_HOST', 'localhost') | ||
try: | ||
PORT = int(environ.get('SERVER_PORT', '3000')) | ||
PORT = int(environ.get('SERVER_PORT', '5555')) | ||
except ValueError: | ||
PORT = 3000 | ||
app.run(HOST, PORT) | ||
PORT = 5555 | ||
app.run(HOST, PORT, debug=True) |