-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlambda_function.py
45 lines (36 loc) · 1.07 KB
/
lambda_function.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import json
import os
def lambda_handler(event, context):
err_resp = {
'statusCode': '400',
'headers': {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, OPTIONS'
}
}
if not 'body' in event:
resp = {
'statusCode': 200,
'headers': {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, OPTIONS'
}
}
return resp
ev = json.loads(event['body'])
if not (('password' in ev) and ('origin' in ev)):
return err_resp
pa = ev['password']
ori = ev['origin']
if pa != os.environ['password']:
return err_resp
url = os.environ['index'] if ori == 'index' else os.environ['join']
response = {
'statusCode': 200,
'body': url,
'headers': {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, OPTIONS'
}
}
return response