title: Return HTML from AWS API Gateway
body: <p>I am trying to achieve the same thing as <a href="https://stackoverflow.com/questions/31779868/get-aws-lambda-response-as-an-html-page">this post</a>, but I do not understand the reply there and don't have permission to ask for clarification in the comments.</p>
  
  <p>I have an API Gateway endpoint that accepts a GET request, passes through some request variables to the Lambda function (implemented in Python), and returns text/html via an Empty Response Model (as described <a href="https://forums.aws.amazon.com/thread.jspa?threadID=195218" rel="nofollow noreferrer">here</a></p>
  
  <p>As described in the earlier SO question, if the Lambda function returns an HTML string and the API endpoint uses the default Output Passthrough behavior @ Integration Response, the HTML output is quoted:</p>
  
  <pre><code>"\n&lt;html&gt;\n&lt;body&gt;\n ... \n&lt;/body&gt;\n&lt;/html&gt;\n"
  </code></pre>
  
  <p>That answer (by @ARUNBALAN NV) says "Simply store the HTML markup in a variable and return it.", but I am unsure what that means in the context of a Lambda function.  Does it mean to return an "application/json" response with an element named "variableHTML"?  Something like this?</p>
  
  <pre><code>"{\"variableHTML\": \"\\n&lt;html&gt;\\n&lt;body&gt;\\n ... \\n&lt;/body&gt;\\n&lt;/html&gt;\\n\"}"
  </code></pre>
  
  <p>I set that up &amp; in API Gateway my Integration Response now uses a Mapping to extract the element (for 200 application/json responses) exactly as suggested:</p>
  
  <pre><code>#set($inputRoot = $input.path('$')) 
  $inputRoot.variableHTML .
  </code></pre>
  
  <p>The result is now a single dot being returned.</p>
  
  <p>I have tried many variations ($input.json instead of $input.path, different content types at different stages, etc), but feel the above setup most closely matches the accepted answer from the other thread.</p>
  
  <p>Any insight where I am going wrong with this will be appreciated. Thanks for reading!</p>