Changeset View
Changeset View
Standalone View
Standalone View
swh/web/misc/urls.py
Show All 24 Lines | return render(request, "misc/jslicenses.html", | ||||
{'jslicenses_data': jslicenses_data}) | {'jslicenses_data': jslicenses_data}) | ||||
def _stat_counters(request): | def _stat_counters(request): | ||||
stat = service.stat_counters() | stat = service.stat_counters() | ||||
url = get_config()['history_counters_url'] | url = get_config()['history_counters_url'] | ||||
stat_counters_history = 'null' | stat_counters_history = 'null' | ||||
if url: | if url: | ||||
response = requests.get(url) | try: | ||||
response = requests.get(url, timeout=5) | |||||
stat_counters_history = response.text | stat_counters_history = response.text | ||||
except Exception: | |||||
pass | |||||
json_data = '{"stat_counters": %s, "stat_counters_history": %s}' % ( | json_data = '{"stat_counters": %s, "stat_counters_history": %s}' % ( | ||||
json.dumps(stat), stat_counters_history) | json.dumps(stat), stat_counters_history) | ||||
return HttpResponse(json_data, content_type='application/json') | return HttpResponse(json_data, content_type='application/json') | ||||
urlpatterns = [ | urlpatterns = [ | ||||
url(r'^', include('swh.web.misc.coverage')), | url(r'^', include('swh.web.misc.coverage')), | ||||
url(r'^jslicenses/$', _jslicenses, name='jslicenses'), | url(r'^jslicenses/$', _jslicenses, name='jslicenses'), | ||||
Show All 33 Lines |