|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
import os
|
|
|
|
|
import shutil
|
|
|
|
|
|
|
|
|
|
from flask import Flask
|
|
|
|
|
from flask_sqlalchemy import SQLAlchemy
|
|
|
|
@ -19,26 +20,34 @@ assets = AssetsEnvironment()
|
|
|
|
|
|
|
|
|
|
def create_app():
|
|
|
|
|
|
|
|
|
|
app = Flask(__name__)
|
|
|
|
|
app.config.from_mapping(
|
|
|
|
|
SECRET_KEY='dev',
|
|
|
|
|
#SQLALCHEMY_DATABASE_URI='sqlite:///{}'.format(os.path.join(app.instance_path, 'yadc.db')),
|
|
|
|
|
SQLALCHEMY_DATABASE_URI='postgresql://{}:{}@{}:{}/{}'.format('yadc', 'omegalul', 'localhost', 5432, 'yadc'),
|
|
|
|
|
MAX_CONTENT_LENGTH=10*1024*1024,
|
|
|
|
|
POST_LIST_THUMB_HEIGHT=200,
|
|
|
|
|
POST_UPLOADS=os.path.join(app.instance_path, 'post'),
|
|
|
|
|
INSTANCE_NAME='Darkne.su',
|
|
|
|
|
POSTS_PER_PAGE=8,
|
|
|
|
|
MANAGE_USERS_PER_PAGE=2,
|
|
|
|
|
MANAGE_POSTS_PER_PAGE=2,
|
|
|
|
|
|
|
|
|
|
ALLOW_REGISTER=False,
|
|
|
|
|
|
|
|
|
|
SQLALCHEMY_ECHO=True,
|
|
|
|
|
)
|
|
|
|
|
app = Flask(__name__, instance_relative_config=True)
|
|
|
|
|
app.config.from_pyfile('config.py')
|
|
|
|
|
app.config.from_mapping(POST_UPLOADS=os.path.join(app.instance_path, 'post'), SQLALCHEMY_TRACK_MODIFICATIONS=False)
|
|
|
|
|
# app.config.from_mapping(
|
|
|
|
|
# SECRET_KEY='dev',
|
|
|
|
|
# #SQLALCHEMY_DATABASE_URI='sqlite:///{}'.format(os.path.join(app.instance_path, 'yadc.db')),
|
|
|
|
|
# SQLALCHEMY_DATABASE_URI='postgresql://{}:{}@{}:{}/{}'.format('yadc', 'omegalul', 'localhost', 5432, 'yadc'),
|
|
|
|
|
# MAX_CONTENT_LENGTH=10*1024*1024,
|
|
|
|
|
# POST_LIST_THUMB_HEIGHT=200,
|
|
|
|
|
# POST_UPLOADS=os.path.join(app.instance_path, 'post'),
|
|
|
|
|
# INSTANCE_NAME='Darkne.su',
|
|
|
|
|
# POSTS_PER_PAGE=8,
|
|
|
|
|
# MANAGE_USERS_PER_PAGE=2,
|
|
|
|
|
# MANAGE_POSTS_PER_PAGE=2,
|
|
|
|
|
|
|
|
|
|
# ALLOW_REGISTER=False,
|
|
|
|
|
|
|
|
|
|
# SQLALCHEMY_ECHO=True,
|
|
|
|
|
# )
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
os.makedirs(app.instance_path)
|
|
|
|
|
|
|
|
|
|
# os.makedirs(app.config.get('POST_UPLOADS'))
|
|
|
|
|
for d in ['img', 'jpeg', 'sample', 'thumb']:
|
|
|
|
|
os.makedirs(os.path.join(app.config.get('POST_UPLOADS'), d))
|
|
|
|
|
|
|
|
|
|
# shutil.copyfile(os.path.join(app.root_path, 'config.def.py'), os.path.join(app.instance_path, 'config.py'))
|
|
|
|
|
except OSError:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|