import json
from datetime import datetime
from django.http import HttpResponse


def heartbeat(request):
    """
    Simple view that a loadbalancer can check to verify that the app is up
    """
    output = {
        'date': datetime.now().isoformat()
    }
    return HttpResponse(json.dumps(output, indent=4))

import json
from datetime import datetime
from django.http import HttpResponse
from xmodule.modulestore.django import modulestore


def heartbeat(request):
    """
    Simple view that a loadbalancer can check to verify that the app is up
    """
    output = {
        'date': datetime.now().isoformat(),
        'courses': [course.location for course in modulestore().get_courses()],
    }
    return HttpResponse(json.dumps(output, indent=4))

Make heartbeat url wait for courses to be loaded
Make heartbeat url wait for courses to be loaded

  import json
  from datetime import datetime
  from django.http import HttpResponse
+ from xmodule.modulestore.django import modulestore
  
  
  def heartbeat(request):
      """
      Simple view that a loadbalancer can check to verify that the app is up
      """
      output = {
-         'date': datetime.now().isoformat()
+         'date': datetime.now().isoformat(),
+         'courses': [course.location for course in modulestore().get_courses()],
      }
      return HttpResponse(json.dumps(output, indent=4))
  
Make heartbeat url wait for courses to be loaded
## Code Before:
import json
from datetime import datetime
from django.http import HttpResponse


def heartbeat(request):
    """
    Simple view that a loadbalancer can check to verify that the app is up
    """
    output = {
        'date': datetime.now().isoformat()
    }
    return HttpResponse(json.dumps(output, indent=4))

## Instruction:
Make heartbeat url wait for courses to be loaded
## Code After:
import json
from datetime import datetime
from django.http import HttpResponse
from xmodule.modulestore.django import modulestore


def heartbeat(request):
    """
    Simple view that a loadbalancer can check to verify that the app is up
    """
    output = {
        'date': datetime.now().isoformat(),
        'courses': [course.location for course in modulestore().get_courses()],
    }
    return HttpResponse(json.dumps(output, indent=4))
