From 73effffc894c0ecc2c825d3acb22b35e94fa56d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20M=C3=BCller?= Date: Mon, 17 May 2021 17:32:52 +0200 Subject: [PATCH] BETTERZON-58: Adding access key verification --- Crawler/api.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Crawler/api.py b/Crawler/api.py index 890c39c..d4d7e6d 100644 --- a/Crawler/api.py +++ b/Crawler/api.py @@ -1,3 +1,5 @@ +import os + from flask import Flask from flask_restful import Resource, Api, reqparse @@ -19,8 +21,12 @@ class CrawlerApi(Resource): def post(self): # Accept crawler request here args = parser.parse_args() - crawler.crawl(args['products']) - return args + access_key = os.getenv('CRAWLER_ACCESS_KEY') + if(args['key'] == access_key): + crawler.crawl(args['products']) + return {'message': 'success'} + else: + return {'message': 'Wrong access key'} api.add_resource(CrawlerApi, '/')