Skip to content
Snippets Groups Projects
Commit 45be1f1c authored by danielmyren's avatar danielmyren
Browse files

add route for swe election data, primitive!

parent 73f917f3
No related branches found
No related tags found
No related merge requests found
from flask import Blueprint, current_app, jsonify, request from flask import Blueprint, current_app, jsonify, request
from flask_security import auth_required, logout_user, verify_password, login_user from flask_security import auth_required, logout_user
from models_shared import SweElectionResult
auth = Blueprint("auth", __name__) auth = Blueprint("auth", __name__)
...@@ -10,7 +11,23 @@ def logout(): ...@@ -10,7 +11,23 @@ def logout():
return jsonify(success=True) return jsonify(success=True)
@auth.route("/api/stats") @auth.route("/api/swedish_election", methods=["GET"])
@auth_required() def get_swe_election_data():
def get_data(): """
pass data = request.get_json()
\ No newline at end of file county_code = request.args.get('county_code')
if not county_code:
return jsonify({"errors" : ["County code is required"], "success" : False})
"""
query_results = SweElectionResult.query.filter_by(db_county_code=1).first()
response = {
"county_code": query_results.db_county_code,
"county_name": query_results.db_county_name,
"votes_each_year": query_results.db_votes_each_year
}
print(response)
return jsonify({"data": response, "success": True})
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment