34 lines
779 B
Python
34 lines
779 B
Python
from bottle import request, Bottle
|
|
|
|
from db_handler import DbConnector
|
|
|
|
import auth
|
|
import messages
|
|
|
|
import bcrypt
|
|
# Needet because of: https://github.com/pyca/bcrypt/issues/684
|
|
if not hasattr(bcrypt, '__about__'):
|
|
bcrypt.__about__ = type('about', (object,), {'__version__': bcrypt.__version__})
|
|
|
|
app = Bottle()
|
|
|
|
|
|
def initialize_app():
|
|
db = DbConnector("sqlite:///./data/db.sqlite")
|
|
|
|
@app.hook('before_request')
|
|
def attach_resources():
|
|
request.db_connector = db
|
|
body = request.body.read()
|
|
|
|
return app
|
|
|
|
if __name__ == "__main__":
|
|
initialize_app()
|
|
|
|
app.mount('/user', auth.app)
|
|
app.mount('/messages', messages.app)
|
|
|
|
root_app = Bottle()
|
|
root_app.mount('/api', app)
|
|
root_app.run(host='localhost', port=8080, debug=True) |