58 lines
1.3 KiB
Python
58 lines
1.3 KiB
Python
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.login.logout()
|
|
|
|
@app.route("/delete_flight", methods=['DELETE'])
|
|
def delete_flight():
|
|
return func.index.delete_flight()
|
|
|
|
@app.route("/upload_csv", methods=['POST'])
|
|
def upload_csv():
|
|
return func.index.upload_csv()
|
|
|
|
if __name__ == "__main__":
|
|
app.run(
|
|
host="0.0.0.0",
|
|
port=8889,
|
|
debug=True
|
|
)
|