-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
69 lines (59 loc) · 2.3 KB
/
app.py
File metadata and controls
69 lines (59 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
"""
Flask application for a book management system.
Import necessary modules (Flask, database libraries, etc.).
Create a Flask app instance.
Define routes for different pages (home, search, authors, wishlist, etc.).
Handle form submissions (e.g., for adding a book).
Interact with the database to retrieve and store data.
Render templates to display content.
"""
import secrets
from flask import Flask, redirect, url_for
from flask_cors import CORS
from models import db
from search.search_routes import search_bp
from books.books_routes import books_bp
from book.book_routes import book_bp
from tools.import_routes import import_bp
from authors.authors_routes import authors_bp
from genres.genres_routes import genres_bp
from series.series_routes import series_bp
from downloader.downloader_routes import downloader_bp
from recommendations.recommendations_routes import recommendations_bp
from tools.fix import fix_bp
from tools.ping_routes import ping_bp
from book_collections.collections_routes import collections_bp
from files.file_routes import files_bp
from tools.import_path_routes import import_path_bp
app = Flask(__name__, static_folder='static')
CORS(app) # Enable CORS for all routes
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///books.db' # Use SQLite for simplicity
#app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://booklibrary:booklibrary@localhost:3306/booklibrary'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.config['SECRET_KEY'] = secrets.token_hex(16) # Generate a random secret key
db.init_app(app)
with app.app_context():
db.create_all()
app.register_blueprint(search_bp)
app.register_blueprint(books_bp)
app.register_blueprint(book_bp)
app.register_blueprint(import_bp)
app.register_blueprint(authors_bp)
app.register_blueprint(genres_bp)
app.register_blueprint(series_bp)
app.register_blueprint(downloader_bp)
app.register_blueprint(recommendations_bp)
app.register_blueprint(fix_bp)
app.register_blueprint(ping_bp)
app.register_blueprint(collections_bp)
app.register_blueprint(files_bp)
app.register_blueprint(import_path_bp)
@app.route('/')
def home():
return redirect(url_for('books.list_books'))
if __name__ == '__main__':
app.run(debug=True)
with app.app_context():
db.create_all()
# TODO re-enable later
#downloader.schedule_cover_download(app)