Notes#
- Studied Flask framework for 76 days.
- Flask is a web framework for Python used to build web applications.
- The usage of Flask feels mismatched.
- Use
static_url_path
to configure the directory for accessing static resources. app.route
defines the route access.@app.route('/')
is the root directory, and Flask automatically calls theindex()
function.- Today's coding exercise is to write two pages, and I have briefly written them.
- Studied HTML and CSS content for days 73-75, but it was too simple to record.
CODE#
from flask import Flask
import datetime
app = Flask(__name__, static_url_path="/static")
@app.route('/')
def index():
page = """
<html>
<head>
<title>David's World Of Baldies</title>
</head>
<body>
<h1>Two Links</h1>
<h2><a href=/portfolio>portfolio</a></h2>
<h2><a href=/linktree>linktree</a></h2>
</body>
</html>
"""
return page
@app.route('/portfolio')
def portfolio():
page = """
<html>
<head>
<title>portfolio</title>
</head>
<body>
<h1>portfolio</h1>
<p>This is portfolio</p>
<p><img src=static/images/picard.jpg/></p>
<p><a href=/>Go Home</a></p>
</body>
</html>
"""
return page
@app.route('/linktree')
def linktree():
page = """
<html>
<head>
<title>linktree</title>
</head>
<body>
<h1>linktree</h1>
<p>This is linktree</p>
<p><a href=/>Go Home</a></p>
</body>
</html>
"""
return page
app.run(host='0.0.0.0', port=81)