import sys import logging # Render Angular Template from Controllers.Main.TemplateController import TemplateController # Login Controller from Controllers.Main.UserController import UserController from Controllers.BaseController import BaseController _basedir = os.path.abspath(os.path.dirname(__file__)) app = Flask(__name__) # app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://///' + os.path.join(_basedir, 'data/congregation.db') db.init_app(app) api = Api(app) # API Routes from Controllers.Addresses.AddressController import AddressController api.add_resource(AddressController, '/address/<int:address_id>') from Controllers.Addresses.GeolocationController import GeolocationController api.add_resource(GeolocationController, '/geolocation/<int:address_id>') from Controllers.Addresses.AddressesListController import AddressesListController api.add_resource(AddressesListController, '/addresses') from Controllers.Addresses.FetchAddressesController import FetchAddressesController api.add_resource(FetchAddressesController, '/fetch')
from resources.SampleResource import SampleResource, SamplesResource, SampleByLocationResource, RecentSamples, SampleYearsResource from resources.WaterschapResource import WaterschapResource, WaterschappenResource from resources.TaxonResource import TaxonResource, TaxonsResource, TaxonByIdsResource, TaxonFindResource, TaxonFamilyResource from resources.TaxonGroupResource import TaxonGroupResource, TaxonGroupsResource from resources.TaxonLevelResource import TaxonLevelResource, TaxonLevelsResource from resources.WatertypeResource import WatertypeResource, WatertypesResource from resources.UserGroupResource import UserGroupResource, UserGroupsResource # Flask framework used as REST API app = Flask(__name__) #app.config["SQLALCHEMY_DATABASE_URI"] = "mysql://*****:*****@127.0.0.1/waterscan" app.config[ "SQLALCHEMY_DATABASE_URI"] = "mysql://*****:*****@127.0.0.1/waterscan" app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False api = Api(app) db.init_app(app) CORS(app) # The different resources linked to a specific path which can be found by the client api.add_resource(AdminResource, "/admin") api.add_resource(AdminResetResource, "/admin/password") api.add_resource(LoginUserResource, "/authenticate/login") api.add_resource(UserChangePasswordResource, "/user/editpassword") api.add_resource(CalculateResource, "/calculate/sample/<int:id>") api.add_resource(SampleTaxonResource, "/calculate/sample2/<int:id>") # new sample api.add_resource(ReferencetaxonResourceValue, "/calculate/reference2/<int:id>") api.add_resource(CalulateReferenceResource, "/calculate/reference/<int:id>") api.add_resource(LocationResource, "/location/id/<int:id>") api.add_resource(LocationByCodeResource, "/location/code/<string:code>") api.add_resource(LocationsResource, "/location/all")
def init_db(): db.init_app(app) with app.app_context(): db.create_all()