Primer upload
This commit is contained in:
32
files/__init__.py
Normal file
32
files/__init__.py
Normal file
@@ -0,0 +1,32 @@
|
||||
import os
|
||||
|
||||
from flask import Flask
|
||||
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'),
|
||||
UPLOAD_FOLDER='uploads'
|
||||
)
|
||||
|
||||
app.config.from_pyfile('config.py', silent=True)
|
||||
app.wsgi_app = SharedDataMiddleware(app.wsgi_app, { '/uploads': app.config['UPLOAD_FOLDER'] })
|
||||
|
||||
try:
|
||||
os.makedirs(app.instance_path)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
from . import db
|
||||
db.init_app(app)
|
||||
|
||||
from . import auth
|
||||
app.register_blueprint(auth.bp)
|
||||
|
||||
from . import files
|
||||
app.register_blueprint(files.bp)
|
||||
app.add_url_rule('/', endpoint='index')
|
||||
|
||||
return app
|
||||
Reference in New Issue
Block a user