Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@http('GET', '/headers')
def do_headers(self, request):
return 201, {'x-foo': 'bar'}, 'created'
@http('POST', '/check/one')
@required_parameters('url')
def check_one(self, data):
url = data.get('url')
group = data.get('group')
callback_url = data.get('callback_url')
url_hash = generate_hash_for('url', url)
log('Checking "{url}" ({hash}) in group "{group}"'.format(
url=url, hash=url_hash, group=group))
self.fetch(url, group=group, callback_url=callback_url)
return json.dumps({'url-hash': url_hash}, indent=2)
@http('GET', '/csv')
@required_parameters()
def csv_report(self, data):
log('CSV report')
all_urls = self.storage.get_all_urls()
if not all_urls:
return 404, ''
filters, excludes = extract_filters(data)
return compute_csv(all_urls, filters, excludes)
@http('GET', '/')
def home(self, request):
messages = self.message_service.get_all_messages()
rendered_template = self.jinja.render_home(messages)
html_response = create_html_response(rendered_template)
return html_response
@http('POST', '/books')
def demo_post(self, request):
return Response(json.dumps({'book': request.data.decode()}),
mimetype='application/json')
@http('GET', '/foo')
def foo(self, request):
if not self.foo_enabled:
return 403, "FeatureNotEnabled"
return 'foo'
@http('POST', '/conf')
def http_set_conf(self, request):
data = request.get_data()
if data:
return self.set_conf(data)
else:
return '400', 'Please pass the valid parameters.'
@http('GET', '/conf')
def http_get_conf(self, request):
output = self.get_conf()
if type(output) == str:
return output
else:
return json.dumps(output)
@http('POST', '/start')
def http_start(self, request):
return self.start(target="all")
@http('PUT', '/conf')
def http_edit_conf(self, request):
data = request.get_data()
if data:
self.edit_conf(target="all", data=data)
return self.http_get_conf(request)
else:
return 400, 'Please pass valid config data.'