forked from carlozamagni/bookly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
61 lines (44 loc) · 1.57 KB
/
app.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
from flask import Flask, render_template, session
from flask.ext.mongoengine import MongoEngine
from flask.ext.login import LoginManager
from flask.ext.admin import Admin
import infrastructure
import sys
app = Flask(__name__)
app.config['SECRET_KEY'] = '123456790'
# db config
app.config['MONGODB_SETTINGS'] = {'DB': 'testing', 'HOST': 'mongodb://bookly:[email protected]:59509/bookly'}
#app.config['MONGODB_SETTINGS'] = {'DB': 'testing', 'HOST': 'mongodb://localhost:27017/bookly'}
db = MongoEngine()
db.init_app(app)
admin = Admin(app)
# login init
lm = LoginManager()
lm.init_app(app)
lm.login_view = '/user/login'
setattr(sys.modules['infrastructure'], 'login_manager', lm)
setattr(sys.modules['infrastructure'], 'admin', admin)
setattr(sys.modules['infrastructure'], 'db', db)
# Authentication
from areas.user.auth import user_app
app.register_blueprint(blueprint=user_app, url_prefix='/user')
# Books to offer
from areas.catalog.catalog import catalog_app
app.register_blueprint(blueprint=catalog_app, url_prefix='/catalog')
# Books to find
from areas.wanted.wanted import wanted_app
app.register_blueprint(blueprint=wanted_app, url_prefix='/wanted')
# Book endpoint
from areas.catalog.book import book_app
app.register_blueprint(blueprint=book_app, url_prefix='/book')
# Search API
from areas.api.search import api
app.register_blueprint(blueprint=api, url_prefix='/api')
@app.route('/')
def home():
return render_template('home.html')
@app.route("/favicon.ico")
def favicon():
return app.send_static_file("favicon.ico")
if __name__ == '__main__':
app.run()