diff --git a/ccvpn/urls.py b/ccvpn/urls.py index d4731de..d3e6927 100644 --- a/ccvpn/urls.py +++ b/ccvpn/urls.py @@ -13,6 +13,7 @@ urlpatterns = [ url(r'^admin/referrers$', account_views.admin_ref, name='admin_ref'), url(r'^admin/', include(admin.site.urls)), + url(r'^api/locations$', account_views.api_locations), url(r'^api/auth$', account_views.api_auth), url(r'^$', views.index, name='index'), diff --git a/lambdainst/views.py b/lambdainst/views.py index eb5226b..67e5463 100644 --- a/lambdainst/views.py +++ b/lambdainst/views.py @@ -300,6 +300,18 @@ def api_auth(request): return JsonResponse(dict(status='ok')) +def api_locations(request): + def format_loc(cc, l): + return { + 'country_name': l['country_name'], + 'country_code': cc, + 'hostname': l['hostname'], + 'bandwidth': l['bandwidth'], + 'servers': l['servers'], + } + return JsonResponse(dict(locations=[format_loc(cc, l) for cc, l in get_locations()])) + + def status(request): locations = get_locations()