0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Lambda からのREST_APIをAPI GatewayでマッピングテンプレートでHTML変換する

Last updated at Posted at 2020-08-19

Lambda関数

import boto3
from boto3.dynamodb.conditions import Key, Attr

def main(nam):
#def lambda_handler(event, context):
    region = "us-east-2"
    dynamodb = boto3.resource('dynamodb')
    table    = dynamodb.Table('testUser')
    response = table.query(KeyConditionExpression=Key('name').eq(nam))
    sites = response["Items"]
    print(sites)
    return sites

API Gateway

マッピングテンプレート

#set($inputRoot = $input.path('$')) 
#foreach($elem in $inputRoot) 
<table border="1">
<tbody>
<tr>
<td>name</td>
<td>charge</td>
<td>email</td>
</tr>
<tr>
<td>"$elem.name"</td>
<td>"$elem.charge"</td>
<td>"$elem.email"</td>
</tr>
</tbody>
</table>
#end
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?