diff --git a/server/requirements.txt b/server/requirements.txt index b0ea661a1..55f85d080 100644 --- a/server/requirements.txt +++ b/server/requirements.txt @@ -32,6 +32,7 @@ requests-async==0.5.0 rfc3986==1.3.2 sanic==19.9.0 Sanic-Cors==0.10.0.post3 +sanic-gzip==0.3.0 Sanic-Plugins-Framework==0.9.2 six==1.14.0 sodapy==2.0.0 diff --git a/server/src/app.py b/server/src/app.py index 47cedd430..087b91794 100644 --- a/server/src/app.py +++ b/server/src/app.py @@ -2,6 +2,7 @@ from sanic import Sanic from sanic.response import json from sanic_cors import CORS +from sanic_gzip import Compress from configparser import ConfigParser from threading import Timer from datetime import datetime @@ -16,6 +17,7 @@ app = Sanic(__name__) CORS(app) +compress = Compress() def configure_app(): @@ -32,11 +34,13 @@ def configure_app(): @app.route('/') +@compress.compress() async def index(request): return json('You hit the index') @app.route('/timetoclose') +@compress.compress() async def timetoclose(request): ttc_worker = time_to_close(app.config['Settings']) @@ -51,6 +55,7 @@ async def timetoclose(request): @app.route('/requestfrequency') +@compress.compress() async def requestfrequency(request): freq_worker = frequency(app.config['Settings']) @@ -62,6 +67,7 @@ async def requestfrequency(request): @app.route('/sample-data') +@compress.compress() async def sample_route(request): sample_dataset = {'cool_key': ['value1', 'value2'], app.config['REDACTED']: app.config['REDACTED']} @@ -69,6 +75,7 @@ async def sample_route(request): @app.route('/ingest', methods=["POST"]) +@compress.compress() async def ingest(request): """Accept POST requests with a list of years to import. Query parameter name is 'years', and parameter value is @@ -90,6 +97,7 @@ async def ingest(request): @app.route('/update') +@compress.compress() async def update(request): ingress_worker = ingress_service() return_data = ingress_worker.update() @@ -97,6 +105,7 @@ async def update(request): @app.route('/delete') +@compress.compress() async def delete(request): ingress_worker = ingress_service() return_data = ingress_worker.delete() @@ -104,6 +113,7 @@ async def delete(request): @app.route('/pins', methods=["POST"]) +@compress.compress() async def pinMap(request): pin_worker = PinService(app.config['Settings']) postArgs = request.json @@ -128,6 +138,7 @@ async def requestDetails(request, srnumber): @app.route('/test_multiple_workers') +@compress.compress() async def test_multiple_workers(request): Timer(10.0, print, ["Timer Test."]).start() return json("Done")