2017-01-29 21:06:08 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2019-07-13 20:45:48 +02:00
|
|
|
# This file is part of the Calibre-Web (https://github.com/janeczku/calibre-web)
|
|
|
|
# Copyright (C) 2012-2019 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/>.
|
|
|
|
|
|
|
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
2015-08-02 20:59:11 +02:00
|
|
|
import sys
|
2019-07-13 20:45:48 +02:00
|
|
|
import os
|
2016-12-23 09:53:39 +01:00
|
|
|
|
2015-08-02 20:59:11 +02:00
|
|
|
|
2019-07-13 20:45:48 +02:00
|
|
|
# Insert local directories into path
|
|
|
|
if sys.version_info < (3, 0):
|
|
|
|
sys.path.append(os.path.dirname(os.path.abspath(__file__.decode('utf-8'))))
|
|
|
|
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__.decode('utf-8'))), 'vendor'))
|
|
|
|
else:
|
|
|
|
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'vendor'))
|
2015-08-02 20:59:11 +02:00
|
|
|
|
2018-07-09 18:47:36 +02:00
|
|
|
|
2020-12-11 15:53:10 +01:00
|
|
|
from cps import create_app, config
|
2019-07-13 20:45:48 +02:00
|
|
|
from cps import web_server
|
|
|
|
from cps.opds import opds
|
|
|
|
from cps.web import web
|
|
|
|
from cps.jinjia import jinjia
|
|
|
|
from cps.about import about
|
|
|
|
from cps.shelf import shelf
|
|
|
|
from cps.admin import admi
|
|
|
|
from cps.gdrive import gdrive
|
|
|
|
from cps.editbooks import editbook
|
2020-12-13 09:53:18 +01:00
|
|
|
from cps.remotelogin import remotelogin
|
2020-12-12 15:16:22 +01:00
|
|
|
from cps.error_handler import init_errorhandler
|
2020-01-11 19:10:39 +01:00
|
|
|
|
|
|
|
try:
|
2020-01-27 20:32:37 +01:00
|
|
|
from cps.kobo import kobo, get_kobo_activated
|
2020-01-11 19:10:39 +01:00
|
|
|
from cps.kobo_auth import kobo_auth
|
2020-01-27 20:32:37 +01:00
|
|
|
kobo_available = get_kobo_activated()
|
2020-01-11 19:10:39 +01:00
|
|
|
except ImportError:
|
|
|
|
kobo_available = False
|
2019-11-06 05:18:52 +01:00
|
|
|
|
2019-07-13 20:45:48 +02:00
|
|
|
try:
|
|
|
|
from cps.oauth_bb import oauth
|
|
|
|
oauth_available = True
|
|
|
|
except ImportError:
|
|
|
|
oauth_available = False
|
2018-07-09 18:47:36 +02:00
|
|
|
|
|
|
|
|
2019-07-13 20:45:48 +02:00
|
|
|
def main():
|
|
|
|
app = create_app()
|
2020-12-12 15:16:22 +01:00
|
|
|
|
|
|
|
init_errorhandler()
|
|
|
|
|
2019-07-13 20:45:48 +02:00
|
|
|
app.register_blueprint(web)
|
|
|
|
app.register_blueprint(opds)
|
|
|
|
app.register_blueprint(jinjia)
|
|
|
|
app.register_blueprint(about)
|
|
|
|
app.register_blueprint(shelf)
|
|
|
|
app.register_blueprint(admi)
|
2020-12-13 09:53:18 +01:00
|
|
|
app.register_blueprint(remotelogin)
|
2020-12-12 15:16:22 +01:00
|
|
|
# if config.config_use_google_drive:
|
|
|
|
app.register_blueprint(gdrive)
|
2019-07-13 20:45:48 +02:00
|
|
|
app.register_blueprint(editbook)
|
2020-01-11 19:10:39 +01:00
|
|
|
if kobo_available:
|
|
|
|
app.register_blueprint(kobo)
|
|
|
|
app.register_blueprint(kobo_auth)
|
2019-07-13 20:45:48 +02:00
|
|
|
if oauth_available:
|
|
|
|
app.register_blueprint(oauth)
|
|
|
|
success = web_server.start()
|
|
|
|
sys.exit(0 if success else 1)
|
2018-07-09 18:47:36 +02:00
|
|
|
|
|
|
|
|
2019-07-13 20:45:48 +02:00
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|