def setUpClass(cls): app.config["TESTING"] = True app.config["AUTH_PROVIDER"] = "none" app.config[ "SQLALCHEMY_DATABASE_URI"] = "sqlite:////tmp/datalayer-test.db" # import pdb; pdb.set_trace() api.add_namespace(protocols) api.add_namespace(runs)
from flask import jsonify, request from flask_restx import Namespace, Resource from server import app, api from server.routes import prometheus from server.services import eval_service calc_namespace = Namespace('calculation', description='simple calculator') api.add_namespace(calc_namespace) @calc_namespace.route("") class Calculator(Resource): @api.param('expr', description='expression', type='string') @prometheus.track_requests def get(self): return jsonify({"result": eval_service.safe_eval(request.args.get("expr"))})
from flask import jsonify from flask_restx import Namespace, Resource from server import app, api from server.routes import prometheus health_namespace = Namespace('health', description='Return Application Health') api.add_namespace(health_namespace) @health_namespace.route("") class Health(Resource): @prometheus.track_requests def get(self): state = {"status": "UP"} return jsonify(state)
from flask_restx import abort, Namespace, Resource, fields from server import app, api from server.routes import prometheus from server.services import user_service LOG = logging.getLogger(__name__) # Only doing this as we're not using a database # this is NOT recommended user_data = user_service.UserService() user_namespace = Namespace('user', description='Interface for User Resource') api.add_namespace(user_namespace) user_fields = api.model('User', { 'name': fields.String }) @user_namespace.route("") class User(Resource): @prometheus.track_requests @api.param('id', description='user id', type='integer') def get(self): if not request.args.get('id'): response = user_data.get_users()
import config from server import server, api # Import Models and Schemas from models import ToDo from schemas import todos_schema, todo_schema # Import Routes from routes import todosRoute # Import Error Handlers from routes import errorHandlers # Register Error Handlers server.register_blueprint(errorHandlers) # Add Routes to API api.add_namespace(todosRoute, path='/todos') # Start Server if __name__ == '__main__': server.run(port=3000, debug=config.debug)
"""Sets up a flask-restx server for running the swabseq analysis R-script.""" from server import app, api from api.swabseq import api as swabseq from api.health import api as server_health api.add_namespace(swabseq) api.add_namespace(server_health) if __name__ == '__main__': app.run()