Skip to content

Commit

Permalink
Rename lambda function to adhere with structure required by AWS lambda.
Browse files Browse the repository at this point in the history
  • Loading branch information
niccolozanotti committed Sep 4, 2024
1 parent 495b26c commit 2c2878b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy-lambda-to-aws.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
cd package
zip -r9 ../lambda_function.zip .
cd ..
zip -g lambda_function.zip registration-app.py
zip -g lambda_function.zip lambda-function.py
- name: Deploy to AWS Lambda
env:
Expand Down
8 changes: 4 additions & 4 deletions registration-app.py → lambda_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from datetime import datetime, timezone
import csv
import boto3
import os


app = Flask(__name__)
CORS(app, resources={r"/*": {"origins": "*"}}, supports_credentials=True)
Expand All @@ -26,16 +26,16 @@ def register():
name = data['name']
occupants.add(name)
log_action(name, 'register')
return jsonify({"status": "registered", "occupants": len(occupants)})
return jsonify({"status": "registered", "occupants": list(occupants)})


@app.route('/unregister', methods=['POST'])
def unregister():
data = request.json
name = data['name']
occupants.remove(name)
occupants.discard(name) # set.discard() avoids KeyError if name not in set
log_action(name, 'unregister')
return jsonify({"status": "unregistered", "occupants": len(occupants)})
return jsonify({"status": "unregistered", "occupants": list(occupants)})


@app.route('/status', methods=['GET'])
Expand Down

0 comments on commit 2c2878b

Please sign in to comment.