二手产品经理

二手产品经理

THIS IS RENO

html, css, flask - 73 days~76 days - Learn Python online for 100 days.

Notes#

  1. Studied Flask framework for 76 days.
  2. Flask is a web framework for Python used to build web applications.
  3. The usage of Flask feels mismatched.
  4. Use static_url_path to configure the directory for accessing static resources.
  5. app.route defines the route access. @app.route('/') is the root directory, and Flask will automatically call the index() function.
  6. Today's code exercise is to write two pages, and I have briefly written them.
  7. Skipped recording the content of learning HTML and CSS for days 73-75 because it was too simple.

CODE#

from flask import Flask
import datetime  # import the datetime library

app = Flask(__name__, static_url_path="/static")

@app.route('/')
def index():
    page = f"""
     <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 = f"""
    <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 = f"""
    <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)  # Missed the run command

Translation:

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.