Comenzando a utilizar SQLAlchemy
Tuve que reescribir bastante para lograrlo, pero ya funciona :3
This commit is contained in:
@@ -3,42 +3,45 @@ import os
|
||||
from flask import Flask, render_template
|
||||
from werkzeug import SharedDataMiddleware
|
||||
|
||||
|
||||
def create_app():
|
||||
app = Flask(__name__, instance_relative_config=True)
|
||||
|
||||
app.config.from_mapping(
|
||||
DATABASE = os.path.join(app.instance_path, 'files.sqlite'),
|
||||
USERNAME = 'dev',
|
||||
PASSWORD = 'secret',
|
||||
SECRET_KEY = '1337',
|
||||
UPLOAD_FOLDER = 'uploads',
|
||||
ALLOWED_EXTENSIONS = set(['png', 'jpg'])
|
||||
SQLALCHEMY_DATABASE_URI="sqlite:///{}".format(os.path.join(app.instance_path, 'files.sqlite')),
|
||||
SQLALCHEMY_TRACK_MODIFICATIONS=False,
|
||||
USERNAME='dev',
|
||||
PASSWORD='secret',
|
||||
SECRET_KEY='1337',
|
||||
UPLOAD_FOLDER='uploads'
|
||||
)
|
||||
|
||||
app.config.from_pyfile('config.py')
|
||||
app.wsgi_app = SharedDataMiddleware(app.wsgi_app, { '/uploads': app.config['UPLOAD_FOLDER'] })
|
||||
app.wsgi_app = SharedDataMiddleware(app.wsgi_app, {'/uploads': app.config['UPLOAD_FOLDER']})
|
||||
|
||||
try:
|
||||
os.makedirs(app.instance_path)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
from . import db
|
||||
from files.models import db
|
||||
db.init_app(app)
|
||||
|
||||
from . import auth
|
||||
from files import commands
|
||||
commands.init_app(app)
|
||||
|
||||
from files import auth
|
||||
app.register_blueprint(auth.bp)
|
||||
|
||||
from . import categories
|
||||
from files import categories
|
||||
app.register_blueprint(categories.bp)
|
||||
|
||||
from . import about
|
||||
from files import about
|
||||
app.register_blueprint(about.bp)
|
||||
app.add_url_rule('/about', endpoint='about')
|
||||
|
||||
from . import files
|
||||
from files import files
|
||||
app.register_blueprint(files.bp)
|
||||
app.add_url_rule('/', endpoint='index')
|
||||
|
||||
|
||||
return app
|
||||
|
||||
Reference in New Issue
Block a user