# coding: utf-8
from flask import Flask
from flask.logging import default_handler

import logging
import sys
import os


class Config:
	SECRET_KEY = os.environ.get('SECRET_KEY')
	SQLALCHEMY_TRACK_MODIFICATIONS = False
	SQLALCHEMY_ECHO = False
	DEBUG = os.environ.get('DEBUG')
	SESSION_COOKIE_DOMAIN = os.environ.get('COOKIE_DOMAIN')
	SQLALCHEMY_DATABASE_URI = os.environ.get('SQLALCHEMY_DATABASE_URI')
	MAIL_DEBUG = int(os.environ.get('DEBUG') == True)

#if sys.version_info.major < 3:
#    reload(sys)
#sys.setdefaultencoding('utf8')



def create_app(config_class=Config):
	app = Flask(__name__)
	app.config.from_object(config_class)

	if app.debug:
		app.logger.setLevel(logging.DEBUG)
	else:
		app.logger.setLevel(logging.INFO)



	from webinterface.content.main import main
	app.register_blueprint(main)

	return app
