<s> import os <EOL> import sys <EOL> import logging <EOL> from logging . handlers import RotatingFileHandler <EOL> from flask import Flask <EOL> from flask . ext import uploads <EOL> from flask . ext . misaka import Misaka <EOL> from flask . ext . sqlalchemy import SQLAlchemy <EOL> from humanize import naturaltime <EOL> from werkzeug . contrib . cache import SimpleCache <EOL> from web_ui . helpers import localtime <EOL> app = Flask ( '<STR_LIT>' ) <EOL> db = SQLAlchemy ( app ) <EOL> app . config . from_object ( "<STR_LIT>" ) <EOL> app . jinja_env . filters [ '<STR_LIT>' ] = naturaltime <EOL> app . jinja_env . filters [ '<STR_LIT>' ] = lambda value : localtime ( value , tzval = app . config [ "<STR_LIT>" ] ) <EOL> Misaka ( app ) <EOL> if not os . path . exists ( app . config [ "<STR_LIT>" ] ) : <EOL> os . makedirs ( app . config [ "<STR_LIT>" ] , <NUM_LIT:0> <NUM_LIT> ) <EOL> cache = SimpleCache ( ) <EOL> attachments = uploads . UploadSet ( '<STR_LIT>' , uploads . IMAGES , <EOL> default_dest = lambda app_x : app_x . config [ "<STR_LIT>" ] ) <EOL> uploads . configure_uploads ( app , ( attachments ) ) <EOL> handlers = [ ] <EOL> loggers = [ app . logger , logging . getLogger ( '<STR_LIT>' ) , logging . getLogger ( '<STR_LIT>' ) ] <EOL> if app . config [ "<STR_LIT>" ] : <EOL> loggers . append ( logging . getLogger ( '<STR_LIT>' ) ) <EOL> if app . config [ "<STR_LIT>" ] is True : <EOL> console_handler = logging . StreamHandler ( stream = sys . stdout ) <EOL> console_handler . setFormatter ( logging . Formatter ( app . config [ '<STR_LIT>' ] ) ) <EOL> handlers . append ( console_handler ) <EOL> if app . config [ "<STR_LIT>" ] is True : <EOL> file_handler = RotatingFileHandler ( app . config [ "<STR_LIT>" ] , <EOL> maxBytes = app . config [ "<STR_LIT>" ] , backupCount = <NUM_LIT:5> , delay = True ) <EOL> file_handler . setFormatter ( logging . Formatter ( app . config [ '<STR_LIT>' ] ) ) <EOL> handlers . append ( file_handler ) <EOL> for l in loggers : <EOL> del l . handlers [ : ] <EOL> l . setLevel ( logging . DEBUG ) <EOL> for h in handlers : <EOL> l . addHandler ( h ) <EOL> l . propagate = False <EOL> def logged_in ( ) : <EOL> """<STR_LIT>""" <EOL> return cache . get ( '<STR_LIT:password>' ) is not None <EOL> import web_ui . views </s>
