| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- def lambda_handler(event, context):
- response = {
- "statusCode": 200,
- "statusDescription": "200 OK",
- "isBase64Encoded": False,
- "headers": {
- "Content-Type": "text/html; charset=utf-8"
- }
- }
- response['body'] = """<html>
- <head>
- <title>Hello World!</title>
- <style>
- html, body {
- margin: 0; padding: 0;
- font-family: arial; font-weight: 700; font-size: 3em;
- text-align: center;
- }
- </style>
- </head>
- <body>
- <p>Hello World!</p>
- </body>
- </html>"""
- return response
- # ====================分割线====================
- import json
- def lambda_handler(event, context):
- response = {
- "statusCode": 200,
- "headers": {
- "Content-Type": "text/plain;"
- },
- "isBase64Encoded": False
- }
- if event['path'] == '/myip':
- sourceip_list = event['headers']['x-forwarded-for'].split(',')
- if sourceip_list:
- sourceip = str(sourceip_list[0])
- response['body']=sourceip
- else:
- response['body']='?.?.?.?'
- return response
- response['body'] = json.dumps(event, indent=2)
-
- return response
|