expose a bobos.json URL to help in local tests

This commit is contained in:
Frédéric Péters 2014-03-25 18:37:21 +01:00
parent c3e14ff5ce
commit 2ec376d44a
2 changed files with 14 additions and 0 deletions

View File

@ -7,5 +7,7 @@ urlpatterns = patterns('',
url(r'^$', 'hobo.views.home', name='home'),
url(r'^environment/', include('hobo.environment.urls')),
url(r'^hobos.json$', 'hobo.views.hobos'),
url(r'^admin/', include(admin.site.urls)),
)

View File

@ -1,3 +1,6 @@
import json
from django.http import HttpResponse
from django.utils.translation import ugettext as _
from django.views.generic.base import TemplateView
@ -17,3 +20,12 @@ class Home(TemplateView):
return context
home = Home.as_view()
def hobos(request, **kwargs):
# The hobos URL is supposed to return a list of hobo websites, this
# dummy implementation makes it possible to point deployment agents to
# a single instance, that will announce itself as the only hobo around.
response = HttpResponse(content_type='application/json')
json.dump([request.build_absolute_uri('/')], response)
return response