code: def v1_trial(request, study_name, trial_id):
      url = "http://127.0.0.1:{}/suggestion/v1/studies/{}/trials/{}".format(
          request.META.get("SERVER_PORT"), study_name, trial_id
      )
  
      if request.method == "GET":
          response = requests.get(url)
  
          tiral_metrics_url = "http://127.0.0.1:{}/suggestion/v1/studies/{}/trials/{}/metrics".format(
              request.META.get("SERVER_PORT"), study_name, trial_id
          )
          tiral_metrics_response = requests.get(tiral_metrics_url)
  
          if response.ok and tiral_metrics_response.ok:
              if six.PY2:
                  trial = json.loads(response.content.decode("utf-8"))[
                      "data"
                  ]
                  trial_metrics = json.loads(
                      tiral_metrics_response.content.decode("utf-8")
                  )["data"]
              else:
                  trial = json.loads(response.text)["data"]
                  trial_metrics = json.loads(
                      tiral_metrics_response.text
                  )["data"]
              context = {
                  "success": True,
                  "trial": trial,
                  "trial_metrics": trial_metrics,
              }
              return render(request, "trial_detail.html", context)
          else:
              response = {
                  "error": True,
                  "message": "Fail to request the url: {}".format(url),
              }
              return JsonResponse(response, status=405)
      elif request.method == "DELETE":
          response = requests.delete(url)
          messages.info(request, response.content)
          return redirect("index")
      elif request.method == "PUT" or request.method == "POST":
          objective_value_string = request.POST.get(
              "objective_value", "1.0"
          )
          objective_value = float(objective_value_string)
          status = request.POST.get("status", "Completed")
          data = {"objective_value": objective_value, "status": status}
          response = requests.put(url, json=data)
          messages.info(request, response.content)
  
          if six.PY2:
              trial = json.loads(response.content.decode("utf-8"))[
                  "data"
              ]
          else:
              trial = json.loads(response.text)["data"]
          context = {
              "success": True,
              "trial": trial,
              "trial_metrics": [],
          }
          return render(request, "trial_detail.html", context)
      else:
          response = {
              "error": True,
              "message": "{} method not allowed".format(request.method),
          }
          return JsonResponse(response, status=405)
  
imports: from __future__ import unicode_literals
  import json
  import requests
  import platform
  import six
  from django.contrib import messages
  from django.shortcuts import redirect
  from django.http import HttpResponse
  from django.views.decorators.csrf import csrf_exempt
  from django.http import JsonResponse
  from django.http import HttpResponseRedirect
  from django.urls import reverse
  from django.http import Http404
  from django.shortcuts import get_object_or_404
  from django.shortcuts import render
  from django.shortcuts import render_to_response
  from django.conf import settings
  from django import forms
  from django.contrib.admin.views.decorators import staff_member_required
  from django.contrib.auth.decorators import login_required
  from suggestion.models import Study
  from suggestion.models import Trial
label_desc: Use image node_id 7 for calling a global function with example usage: v1_trial(request, study_name, trial_id) and returns: render, JsonResponse, redirect, render, JsonResponse