初始化项目
This commit is contained in:
parent
bdca509371
commit
39eae65e25
19
main.py
19
main.py
@ -3,19 +3,14 @@ import requests
|
||||
from flask import Flask, render_template, request, redirect, url_for, session
|
||||
|
||||
app = Flask(__name__)
|
||||
app.secret_key = os.urandom(24)
|
||||
app.config["SESSION_TYPE"] = "filesystem"
|
||||
app.config["SESSION_FILE_DIR"] = "./.flask_session/"
|
||||
app.config["SESSION_PERMANENT"] = False
|
||||
app.config["SESSION_COOKIE_NAME"] = "login"
|
||||
app.config["SESSION_COOKIE_HTTPONLY"] = True
|
||||
app.config["SESSION_COOKIE_SECURE"] = False
|
||||
|
||||
|
||||
|
||||
@app.route("/", methods=["GET", "POST"])
|
||||
def index():
|
||||
if request.method == "POST":
|
||||
session["username"] = request.form["username"]
|
||||
session["password"] = request.form["password"]
|
||||
return redirect(url_for("home"))
|
||||
return render_template("index.html")
|
||||
|
||||
return render_template("index.html")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(host="0.0.0.0")
|
@ -1,8 +1,8 @@
|
||||
<html>
|
||||
<head>
|
||||
<title> Hello World </title>
|
||||
</head>
|
||||
</head>
|
||||
<body>
|
||||
<h1> Hello World </h1>
|
||||
<h1> Hello World </h1>
|
||||
</body>
|
||||
</html>
|
Loading…
x
Reference in New Issue
Block a user