Commit f7fb9019 authored by Fence's avatar Fence 🌈

remove useless APP class

parent 2e101d70
from minor import App
app = App({
"MUSIC_UPLOAD_DIR": "./upload",
"IMAGE_UPLOAD_DIR": "./upload"
})
flask = app.get_application()
import json
from flask import Flask
from minor.controller import ApiController, MusicController, CoverController
from minor.controller import AuthController
from minor.error_handlers import set_error_handlers
from minor.app import App
config = {}
with open('config.json') as json_file:
config = json.load(json_file)
app = Flask(__name__)
app.config['MONGODB_SETTINGS'] = {'db': 'minor'}
app.config['JWT_SEKRIT'] = "sekrit"
app.config.update(config)
set_error_handlers(app)
from minor.model import db
db.init_app(app)
ApiController().register(app)
AuthController(app).register(app)
MusicController(
config["MUSIC_UPLOAD_DIR"],
config["IMAGE_UPLOAD_DIR"]
).register(app)
CoverController(
config["IMAGE_UPLOAD_DIR"]
).register(app)
from flask import Flask
from minor.controller import ApiController, MusicController, CoverController
from minor.controller import AuthController
from minor.error_handlers import set_error_handlers
class App(object):
def __init__(self, config):
self._flask = Flask(__name__)
self._flask.config['MONGODB_SETTINGS'] = {'db': 'minor'}
self._flask.config['JWT_SEKRIT'] = "sekrit"
self._flask.config.update(config)
set_error_handlers(self._flask)
from minor.model import db
db.init_app(self._flask)
ApiController(self).register(self._flask)
AuthController(self).register(self._flask)
MusicController(
self._flask.config["MUSIC_UPLOAD_DIR"],
self._flask.config["IMAGE_UPLOAD_DIR"]
).register(self._flask)
CoverController(
self._flask.config["IMAGE_UPLOAD_DIR"]
).register(self._flask)
def run(self, host="127.0.0.1", port=5000):
self._flask.run(host=host, port=port)
def get_application(self):
return self._flask
......@@ -6,9 +6,6 @@ from minor import version
@route("/api")
class ApiController(FlaskController):
def __init__(self, app):
self._app = app
@route("")
def index(self):
v = {"version": version.number, "name": version.name, "code": 200}
......
......@@ -7,9 +7,8 @@ import minor.crypto
@route("/auth")
class AuthController(FlaskController):
def __init__(self, app):
self._app = app
self._secret = app._flask.config["JWT_SEKRIT"]
def __init__(self, flask):
self._secret = flask.config["JWT_SEKRIT"]
@route("/login", methods=["POST"])
def index(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment