初始化项目

This commit is contained in:
dockermen 2025-04-08 13:27:18 +08:00
parent bdca509371
commit 39eae65e25
2 changed files with 9 additions and 14 deletions

17
main.py
View File

@ -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")
if __name__ == "__main__":
app.run(host="0.0.0.0")

View File

@ -1,8 +1,8 @@
<html>
<head>
<title> Hello World </title>
</head>
</head>
<body>
<h1> Hello World </h1>
<h1> Hello World </h1>
</body>
</html>