Skip to content

Commit

Permalink
Update app.py
Browse files Browse the repository at this point in the history
  • Loading branch information
MX0100 authored Jun 27, 2024
1 parent 16ed75e commit 89b5456
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Safezone-main/src/app.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
import sys

from flask import Flask, render_template, redirect, url_for, flash, session, request, jsonify
from flask_sqlalchemy import SQLAlchemy
from flask_session import Session
from flask_socketio import SocketIO, emit
from datetime import datetime, timedelta
import os
import socket
sys.path.append('../..')
from models import db, User, Content, UserSession

from interceptor import login_required

app = Flask(__name__)
app.config.from_object('config.Config')

db = SQLAlchemy(app)
db.init_app(app)
db.init_app(app) # 初始化db
Session(app)
socketio = SocketIO(app)

# 导入表单和模型
from forms import LoginForm, RegistrationForm, ContentForm
from models import User, Content, UserSession

@app.before_request
def create_tables():
db.create_all()
with app.app_context():
db.create_all()

def validate_session():
session_token = session.get('session_token') or request.args.get('session_token')
Expand Down

0 comments on commit 89b5456

Please sign in to comment.