回覆列表
  • 1 # 使用者7169188564904

    GET方式

    from flask import Flask, render_template, request

    # Initialize the Flask application

    app = Flask(__name__)

    # This is a catch all route, to catch any request the user does

    @app.route("/")

    def index():

    qs = request.query_string

    return render_template("index.html", query_string=qs)

    if __name__ == "__main__":

    app.run(

    host="0.0.0.0",

    port=int("80"),

    )

    POST方式

    from flask import request

    @app.route("/login", methods=["POST", "GET"])

    def login():

    error = None

    if request.method == "POST":

    if valid_login(request.form["username"],

    request.form["password"]):

    return log_the_user_in(request.form["username"])

    else:

    error = "Invalid username/password"

    # the code below is executed if the request method

    # was GET or the credentials were invalid

    return render_template("login.html", error=error)

    當然這些官方的開發文件都有的

  • 中秋節和大豐收的關聯?
  • 用石膏板封牆有什麼利弊?