完成大作业服务端代码,新建管理端,管理端不可用
This commit is contained in:
49
Project/Manager/main.py
Normal file
49
Project/Manager/main.py
Normal file
@@ -0,0 +1,49 @@
|
||||
from flask import Flask, redirect, url_for, session, g
|
||||
from flask_httpauth import HTTPTokenAuth
|
||||
from flask_cors import CORS
|
||||
from func.config import SECRET_KEY
|
||||
|
||||
import func.login
|
||||
import func.index
|
||||
|
||||
app = Flask(__name__)
|
||||
app.config["SECRET_KEY"] = SECRET_KEY
|
||||
app.config["JSON_AS_ASCII"] = False
|
||||
app.config['SESSION_COOKIE_HTTPONLY'] = True
|
||||
app.config['SESSION_COOKIE_SECURE'] = False
|
||||
app.config['SESSION_COOKIE_SAMESITE'] = 'Lax'
|
||||
CORS(app, supports_credentials=True)
|
||||
auth = HTTPTokenAuth(scheme='Bearer')
|
||||
|
||||
@app.before_request
|
||||
def before_request():
|
||||
g.user = None
|
||||
if 'user_id' in session:
|
||||
g.user = session.get('user_id')
|
||||
|
||||
@app.route("/")
|
||||
def home():
|
||||
return redirect(url_for('index'))
|
||||
|
||||
@app.route("/index", methods=['GET'])
|
||||
def index():
|
||||
return func.index.index()
|
||||
|
||||
@app.route("/modify", methods=['POST'])
|
||||
def modify():
|
||||
return func.index.modify()
|
||||
|
||||
@app.route("/login", methods=['GET', 'POST'])
|
||||
def login():
|
||||
return func.login.login()
|
||||
|
||||
@app.route('/logout')
|
||||
def logout():
|
||||
return func.index.logout()
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(
|
||||
host="0.0.0.0",
|
||||
port=8889,
|
||||
debug=True
|
||||
)
|
||||
Reference in New Issue
Block a user