webcrawler v1.0
This commit is contained in:
parent
008e2bc274
commit
6b057fb941
19 changed files with 814 additions and 112 deletions
|
|
@ -2,20 +2,25 @@ import os
|
|||
from flask import Flask, redirect, url_for, request
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
from flask_login import LoginManager, current_user
|
||||
from .models import db, User
|
||||
from flask_migrate import Migrate
|
||||
|
||||
# Konfiguration für Upload- und Ergebnis-Ordner
|
||||
UPLOAD_FOLDER = '/app/uploads'
|
||||
RESULT_FOLDER = '/app/results'
|
||||
|
||||
db = SQLAlchemy()
|
||||
migrate = Migrate()
|
||||
|
||||
def create_app():
|
||||
app = Flask(__name__)
|
||||
app.config['SECRET_KEY'] = '008e7369b075886d5f494c8813efdfb17155da6af12b3fe8ee'
|
||||
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///users.db'
|
||||
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
|
||||
app.config['RESULT_FOLDER'] = RESULT_FOLDER
|
||||
app.config['ALLOW_USER_SIGNUP'] = False
|
||||
|
||||
db.init_app(app)
|
||||
migrate.init_app(app, db)
|
||||
|
||||
# Flask-Login Setup
|
||||
login_manager = LoginManager()
|
||||
|
|
@ -24,16 +29,15 @@ def create_app():
|
|||
|
||||
@login_manager.user_loader
|
||||
def load_user(user_id):
|
||||
from .models import User
|
||||
return User.query.get(int(user_id))
|
||||
|
||||
# Umleitung nicht authentifizierter Benutzer, statische Dateien und bestimmte Routen ausnehmen
|
||||
@app.before_request
|
||||
def require_login():
|
||||
allowed_routes = ['auth.login', 'auth.signup']
|
||||
|
||||
# Prüfen, ob der Benutzer authentifiziert ist oder eine erlaubte Route anfragt
|
||||
if (not current_user.is_authenticated
|
||||
and request.endpoint not in allowed_routes
|
||||
if (not current_user.is_authenticated
|
||||
and request.endpoint not in allowed_routes
|
||||
and not request.path.startswith('/static/')):
|
||||
return redirect(url_for('auth.login'))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue