2022-04-26 09:04:00 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
# This file is part of the Calibre-Web (https://github.com/janeczku/calibre-web)
|
|
|
|
# Copyright (C) 2012-2022 OzzieIsaacs
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
import sys
|
|
|
|
|
2022-09-04 17:47:04 +00:00
|
|
|
from . import create_app, limiter
|
2022-04-26 09:04:00 +00:00
|
|
|
from .jinjia import jinjia
|
2022-09-04 17:47:04 +00:00
|
|
|
from flask import request
|
|
|
|
|
|
|
|
|
|
|
|
def request_username():
|
|
|
|
return request.authorization.username
|
2022-04-26 09:04:00 +00:00
|
|
|
|
2024-06-18 18:13:26 +00:00
|
|
|
|
2022-04-26 09:04:00 +00:00
|
|
|
def main():
|
|
|
|
app = create_app()
|
|
|
|
|
|
|
|
from .web import web
|
2024-11-23 14:46:20 +00:00
|
|
|
from .basic import basic
|
2022-04-26 09:04:00 +00:00
|
|
|
from .opds import opds
|
|
|
|
from .admin import admi
|
|
|
|
from .gdrive import gdrive
|
|
|
|
from .editbooks import editbook
|
|
|
|
from .about import about
|
2022-04-26 09:28:20 +00:00
|
|
|
from .search import search
|
2022-04-26 12:44:55 +00:00
|
|
|
from .search_metadata import meta
|
|
|
|
from .shelf import shelf
|
|
|
|
from .tasks_status import tasks
|
|
|
|
from .error_handler import init_errorhandler
|
2024-07-27 16:42:21 +00:00
|
|
|
from .remotelogin import remotelogin
|
2022-04-28 18:57:09 +00:00
|
|
|
try:
|
|
|
|
from .kobo import kobo, get_kobo_activated
|
|
|
|
from .kobo_auth import kobo_auth
|
2022-09-05 16:45:24 +00:00
|
|
|
from flask_limiter.util import get_remote_address
|
2022-04-28 18:57:09 +00:00
|
|
|
kobo_available = get_kobo_activated()
|
|
|
|
except (ImportError, AttributeError): # Catch also error for not installed flask-WTF (missing csrf decorator)
|
|
|
|
kobo_available = False
|
2024-06-22 11:31:18 +00:00
|
|
|
kobo = kobo_auth = get_remote_address = None
|
2022-04-26 09:04:00 +00:00
|
|
|
|
2022-04-28 19:43:26 +00:00
|
|
|
try:
|
|
|
|
from .oauth_bb import oauth
|
|
|
|
oauth_available = True
|
|
|
|
except ImportError:
|
|
|
|
oauth_available = False
|
2024-06-18 18:13:26 +00:00
|
|
|
oauth = None
|
2022-04-28 19:43:26 +00:00
|
|
|
|
2022-04-26 09:04:00 +00:00
|
|
|
from . import web_server
|
|
|
|
init_errorhandler()
|
|
|
|
|
2022-04-26 09:28:20 +00:00
|
|
|
app.register_blueprint(search)
|
|
|
|
app.register_blueprint(tasks)
|
2022-04-26 09:04:00 +00:00
|
|
|
app.register_blueprint(web)
|
2024-11-23 14:46:20 +00:00
|
|
|
app.register_blueprint(basic)
|
2022-04-26 09:04:00 +00:00
|
|
|
app.register_blueprint(opds)
|
2024-06-18 18:13:26 +00:00
|
|
|
limiter.limit("3/minute", key_func=request_username)(opds)
|
2022-04-26 09:04:00 +00:00
|
|
|
app.register_blueprint(jinjia)
|
|
|
|
app.register_blueprint(about)
|
|
|
|
app.register_blueprint(shelf)
|
2022-04-26 09:28:20 +00:00
|
|
|
app.register_blueprint(admi)
|
2022-04-26 09:04:00 +00:00
|
|
|
app.register_blueprint(remotelogin)
|
|
|
|
app.register_blueprint(meta)
|
|
|
|
app.register_blueprint(gdrive)
|
|
|
|
app.register_blueprint(editbook)
|
|
|
|
if kobo_available:
|
|
|
|
app.register_blueprint(kobo)
|
|
|
|
app.register_blueprint(kobo_auth)
|
2023-02-05 12:43:35 +00:00
|
|
|
limiter.limit("3/minute", key_func=get_remote_address)(kobo)
|
2022-04-26 09:04:00 +00:00
|
|
|
if oauth_available:
|
|
|
|
app.register_blueprint(oauth)
|
|
|
|
success = web_server.start()
|
|
|
|
sys.exit(0 if success else 1)
|