Skip to content

Commit

Permalink
[back] Create a config file for database configuration. (#242)
Browse files Browse the repository at this point in the history
  • Loading branch information
landerneRPi authored Aug 13, 2021
1 parent 7860b78 commit 36a0875
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
10 changes: 10 additions & 0 deletions server/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"MONGODB_SETTINGS": {
"db": "scratchy",
"username": "root",
"password": "example",
"host": "localhost",
"port": 27017,
"authentication_source": "admin"
}
}
14 changes: 6 additions & 8 deletions server/scratchy_server/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,23 @@
from apispec import APISpec
from apispec.ext.marshmallow import MarshmallowPlugin
import logging
import json

from scratchy_server import db_scratchy
from scratchy_server.resources.roomres import RoomRes, AllRoomRes
from scratchy_server.resources.userres import UserRes, AllUserRes
from scratchy_server.resources.messageres import MessageRes, AllMessageRes

# load scratchy configuration from file
with open('config.json', 'r') as config_file:
config_data = json.load(config_file)

logging.basicConfig(level=logging.DEBUG)
app = Flask(__name__)
CORS(app)

app.config['MONGODB_SETTINGS'] = {
'db': 'scratchy',
'username': 'root',
'password': 'example',
'host': 'localhost',
'port': 27017,
'authentication_source': 'admin'
}
# main configuration from config data (file)
app.config.update(config_data)

app.config.update({
'APISPEC_SPEC': APISpec(
Expand Down

0 comments on commit 36a0875

Please sign in to comment.