aboutsummaryrefslogtreecommitdiff
path: root/umosapi/__init__.py
blob: ac93e1dadf6e27cdbbf9fba06b908fbb37a79c1c (plain)
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
# -*- coding: utf-8 -*-
"""
    UMoSApi
    ~~~~~~~

    Unity Mongo Save Api is a simple API for save Unity object in Mongo
    database.

    :copyright: (c) 2019 by neodarz.
    :licence: GPLv3, see LICENSE for more details.
"""
import os

from flask import Flask, render_template

def create_app(test_config=None):
    app = Flask(__name__, instance_relative_config=True)
    app.config.from_mapping(
        SECRET_KEY='dev',
        MONGO_URI="mongodb://localhost:27017/umosapi",
    )

    if test_config is None:
        app.config.from_pyfile('config.py', silent=True)
    else:
        app.config.from_mapping(test_config)

    try:
        os.makedirs(app.instance_path)
    except OSError:
        pass

    from . import api
    app.register_blueprint(api.bp, url_prefix='/api')

    return app