initial
This commit is contained in:
commit
c5d0f1b9b4
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
__pycache__
|
||||
venv
|
||||
1
requirements.txt
Normal file
1
requirements.txt
Normal file
@ -0,0 +1 @@
|
||||
flask
|
||||
8
src/config.py
Normal file
8
src/config.py
Normal file
@ -0,0 +1,8 @@
|
||||
import configparser
|
||||
from os.path import expanduser
|
||||
|
||||
|
||||
def load():
|
||||
config = configparser.ConfigParser()
|
||||
config.read(expanduser("~/.config/mangalpy/config.ini"))
|
||||
return config
|
||||
13
src/db.py
Normal file
13
src/db.py
Normal file
@ -0,0 +1,13 @@
|
||||
import sqlite3
|
||||
|
||||
|
||||
class DB:
|
||||
def __init__(self, path):
|
||||
self.path = path
|
||||
|
||||
def _connect(self):
|
||||
return sqlite3.connect(self.path)
|
||||
|
||||
|
||||
def connect(path):
|
||||
return sqlite3.connect(path)
|
||||
17
src/flask_app.py
Normal file
17
src/flask_app.py
Normal file
@ -0,0 +1,17 @@
|
||||
from routes import root
|
||||
from flask import Flask
|
||||
from os.path import expanduser
|
||||
|
||||
from db import DB
|
||||
import config
|
||||
|
||||
|
||||
class App(Flask):
|
||||
def __init__(self):
|
||||
self.app_config = config.load()
|
||||
db_location = expanduser(self.app_config.get("General", "db_location"))
|
||||
self.db = DB(db_location)
|
||||
super().__init__(__name__)
|
||||
|
||||
def register_blueprints(self):
|
||||
self.register_blueprint(root.bp)
|
||||
13
src/mangalpy.py
Normal file
13
src/mangalpy.py
Normal file
@ -0,0 +1,13 @@
|
||||
import flask_app
|
||||
from os.path import realpath, dirname
|
||||
import sys
|
||||
|
||||
import_dir = dirname(f"{realpath(__file__)}")
|
||||
sys.path.append(import_dir)
|
||||
|
||||
app = flask_app.App()
|
||||
app.register_blueprints()
|
||||
|
||||
# Entry point bby
|
||||
if __name__ == "__main__":
|
||||
app.run(debug=True)
|
||||
1
src/routes/__init__.py
Normal file
1
src/routes/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
from . import root
|
||||
23
src/routes/root.py
Normal file
23
src/routes/root.py
Normal file
@ -0,0 +1,23 @@
|
||||
from flask import Blueprint
|
||||
from flask import current_app
|
||||
|
||||
bp = Blueprint("root", __name__, url_prefix="/")
|
||||
|
||||
|
||||
@bp.route("/")
|
||||
def root():
|
||||
current_app.db._connect()
|
||||
return {
|
||||
"manga": {
|
||||
"somehashofsomething": {
|
||||
"title": "Some lewd shit",
|
||||
"author": "Some weeb",
|
||||
"chapters_downloaded": [0, 1, 2, 3, 4, 5, 6, 7],
|
||||
},
|
||||
"someotherthing": {
|
||||
"title": "Other lewd shit",
|
||||
"author": "Other weeb",
|
||||
"chapters_downloaded": [x for x in range(15)],
|
||||
},
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user