二手产品经理

二手产品经理

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 automatically calls the index() function.
  6. Today's coding exercise is to write two pages, and I have briefly written them.
  7. 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)
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.