Skip to content

Commit

Permalink
Separate our the Metrics api into its own blueprint.
Browse files Browse the repository at this point in the history
  • Loading branch information
dougthor42 committed Mar 21, 2019
1 parent 684541c commit 2353922
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/trendlines/app_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def create_app():
routes.api_class.init_app(app)
routes.api_class.register_blueprint(routes.api)
routes.api_class.register_blueprint(routes.api_datapoint)
routes.api_class.register_blueprint(routes.api_metric)

# Create the database file and populate initial tables if needed.
orm.create_db(app.config['DATABASE'])
Expand Down
6 changes: 4 additions & 2 deletions src/trendlines/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
description="All API.")
api_datapoint = Blueprint("DataPoints", __name__,
description="CRUD datapoint(s)")
api_metric = Blueprint("Metrics", __name__,
description="CRUD metric(s)")


# Make sure all pages show our version.
Expand Down Expand Up @@ -187,7 +189,7 @@ def delete(self, datapoint_id):
return "", 204


@api.route("/api/v1/metric")
@api_metric.route("/api/v1/metric")
class Metric(MethodView):
def get(self):
"""
Expand Down Expand Up @@ -258,7 +260,7 @@ def post(self):
return jsonify(body), 201


@api.route("/api/v1/metric/<metric_name>")
@api_metric.route("/api/v1/metric/<metric_name>")
class MetricById(MethodView):
def get(self, metric_name):
"""
Expand Down

0 comments on commit 2353922

Please sign in to comment.