File indexing completed on 2022-12-06 21:23:21

0001 #!/usr/bin/env python3
0002 # -*- coding: utf-8 -*-
0003 import os,sys
0004 from eve import Eve
0005 from flask import jsonify
0006 import json
0007 
0008 mongo_host = os.environ.get("MONGO_HOST")
0009 service_port = int(os.environ.get('SERVICE_PORT'))
0010 
0011 eve_settings = {}
0012 eve_settings['MONGO_HOST'] = mongo_host
0013 eve_settings['MONGO_DBNAME'] = "courses"
0014 eve_settings['DEBUG'] = True
0015 
0016 eve_settings['SOFT_DELETE'] = True
0017 eve_settings['API_VERSION'] = "v1"
0018 eve_settings['VERSIONING'] = True
0019 eve_settings['XML'] = False
0020 eve_settings['RESOURCE_METHODS'] = ['GET', 'POST']
0021 eve_settings['ITEM_METHODS'] = ['GET', 'PATCH', 'DELETE']
0022 eve_settings['DOMAIN'] = {}
0023 eve_settings['DOMAIN']['courses'] = {
0024     'schema': {
0025         'title': {
0026             'type': 'string',
0027             'required': True
0028         },
0029         'chapters': {
0030             'type': 'list',
0031             'schema': {
0032                 'type': 'dict',
0033                 'schema': {
0034                     '_id': {'type': 'objectid'},
0035                     '_version': {'type': 'integer'}
0036                 },
0037             },
0038         },
0039         'authors': {
0040             'type': 'list',
0041         },
0042         'language': {
0043             'type': 'string',
0044             'required': True
0045         },
0046     },
0047 }
0048 
0049 
0050 app = Eve(settings=eve_settings)
0051 
0052 if __name__ == '__main__':
0053     app.run(host='0.0.0.0', port=service_port)