コード例 #1
0
ファイル: app.py プロジェクト: LoveMyDaughter/ecomap
from datetime import timedelta

from flask import Flask
from flask.ext.cache import Cache
from flask.ext.session import Session
from flask.ext.autodoc import Autodoc
from flask.ext.triangle import Triangle
from werkzeug.contrib.cache import MemcachedCache

from ecomap.config import Config

_CONFIG = Config().get_config()

TEMPLATE_FOLDER = os.path.join(os.environ['PRODROOT'], 'www/templates/')
app = Flask(__name__, template_folder=TEMPLATE_FOLDER)
Triangle(app)
auto = Autodoc(app)

logging.config.fileConfig(os.path.join(os.environ['CONFROOT'], '_log.conf'))
logger = logging.getLogger('flask_app')
app.config['SECRET_KEY'] = 'a7c268ab01141868811c070274413ea3c588733241659fcb'
app.config["REMEMBER_COOKIE_DURATION"] = timedelta(days=14)  # user time lib
app.config['SECRET_KEY'] = _CONFIG['ecomap.secret_key']
app.config['CACHE_TYPE'] = 'memcached'
app.config['SESSION_TYPE'] = 'memcached'
app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(days=14)
app.config['SESSION_MEMCACHED'] = MemcachedCache(
    _CONFIG['ecomap.memcached_servers'])
app.config['CACHE_MEMCACHED_SERVERS'] = _CONFIG['ecomap.memcached_servers']
app.config['OAUTH_CREDENTIALS'] = {
    'facebook': {
コード例 #2
0
# This is where teh application factory function lives
# Import all the necessary Flask extenstions here

from flask import Flask, render_template
from flask.ext.bootstrap import Bootstrap
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.triangle import Triangle

from config import config

db = SQLAlchemy()
triangle = Triangle()


def create_app(config_name):
    app = Flask(__name__, static_path='/static')
    app.config.from_object(config[config_name])

    triangle.init_app(app)

    db.init_app(app)
    from main import main as main_blueprint
    app.register_blueprint(main_blueprint)

    return app
コード例 #3
0
 def __init__(self):
     self.flask = Flask(__name__, static_path="/static")
     Triangle(self.flask)
コード例 #4
0
from flask import Flask
from flask.ext.triangle import Triangle

app = Flask(__name__)  # initialize app
Triangle(app)  # add filter for angular expressions

from app import routes
コード例 #5
0
import json
import logging
import requests
import os
from flask import Flask, render_template, send_from_directory, request, json, jsonify
from flask.ext.triangle import Triangle
from logging.handlers import RotatingFileHandler

application = Flask(__name__)
Triangle(application)


@application.before_first_request
def setup_logging():
    if not application.debug:
        # In production mode, add log handler to sys.stderr.
        application.logger.addHandler(
            RotatingFileHandler('app.log', maxBytes=10000, backupCount=1))
        application.logger.setLevel(logging.INFO)


@application.route('/favicon.ico')
def favicon():
    return send_from_directory(os.path.join(application.root_path, 'static'),
                               'favicon.ico')


@application.route('/', methods=['GET', 'POST'])
def showIndex():
    application.logger.info('Inside showIndex')
    errors = []