-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__init__.py
39 lines (29 loc) · 1.16 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from flask import Flask, g, session, redirect, url_for, request
from flask.ext.assets import Environment, Bundle
from flask.ext.sqlalchemy import SQLAlchemy
from mongokit import Connection
import os
import config
import private
app = Flask(__name__)
app.secret_key = private.secret_key
config.DevelopmentConfig.SQLALCHEMY_DATABASE_URI = private.dev_sql_database
config.ProductionConfig.SQLALCHEMY_DATABASE_URI = private.prod_sql_database
env = os.environ['FLASK_BOOKS_ENV'].lower()
if env == 'dev' or env == 'development':
app.config.from_object(config.DevelopmentConfig)
elif env == 'prod'or env == 'production':
app.config.from_object(config.ProductionConfig)
else:
raise RuntimeError("environment variable FLASK_BOOKS_ENV not set to dev or prod.")
# config assets
assets = Environment(app)
#assets.url = app.static_url_path
scss = Bundle('books.scss', filters='pyscss', output='books.css')
assets.register('scss_all', scss)
db_auth = SQLAlchemy(app)
connection = Connection(app.config['MONGODB_HOST'],
app.config['MONGODB_PORT'])
db = connection[app.config['MONGODB_DB']]
collection = db[app.config['MONGODB_COLLECTION']]
import books.views