from app.config import create_app app = create_app()
def setUp(self): self.app = create_app() self.app_context = self.app.app_context() self.app_context.push() self.client = self.app.test_client()
from data_layer import models from app.config import create_app, model_hec, UPLOADS_DEFAULT_DEST from flask_json import JsonError, json_response from flask import request import datetime import os import ast from app.hec_single import single_util from app.hec_single import model_tasks trig_api, db = create_app(models.db) # Gathering required input files to run single hec-hms model @trig_api.route('/hec_hms/single/init-start', methods=['POST']) def init_hec_hms_single(db): print('init_hec_hms_single') req_args = request.args.to_dict() if 'run-name' not in req_args.keys() or not req_args['run-name']: raise JsonError(status_=400, description='run-name is not specified.') run_name = request.args.get('run-name', type=str) # Model running date default is current date. Folder created for this date. if 'run-datetime' not in req_args.keys() or not req_args['run-datetime']: raise JsonError(status_=400, description='run-datetime is not specified.') run_datetime = datetime.datetime.strptime(request.args.get('run-datetime', type=str), '%Y-%m-%d %H:%M:%S') if 'init-state' not in req_args.keys() or not req_args['init-state']: init_state_path = os.path.join(UPLOADS_DEFAULT_DEST, run_datetime.strftime('%Y-%m-%d'), run_name, '2008_2_Events/basinStates') init_state = single_util.is_init_state(db, run_datetime.strftime('%Y-%m-%d'), init_state_path)
def app(request): app = config.create_app(config.app, {"TESTING": True}) yield app
from app import config if __name__ == '__main__': app = config.create_app(config.app) app.run()