Skip to content

Instantly share code, notes, and snippets.

@admiral0
Last active July 2, 2019 21:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save admiral0/77f631239940adc4f6e7b507274d7a77 to your computer and use it in GitHub Desktop.
Save admiral0/77f631239940adc4f6e7b507274d7a77 to your computer and use it in GitHub Desktop.
import json
import boto3
from datetime import datetime
ddb = boto3.client('dynamodb')
def lambda_handler(event, context):
today = datetime.utcnow().strftime('%d%m%Y')
try:
lulz = ddb.get_item(TableName='morti-di-stima', Key={'data': {'S': today}})['Item']['morti']['S']
except:
lulz = 0
res = '<h1>' + lulz + '</h1>'
res += '''
<form action="/" method="post">
<input type="submit" value="RIP (+1 morte)"/>
</form>
'''
return {
"statusCode": 200,
"body": res,
"headers": {
'Content-Type': 'text/html',
}
}
import json
import boto3
from datetime import datetime
ddb = boto3.client('dynamodb')
def lambda_handler(event, context):
today = datetime.utcnow().strftime('%d%m%Y')
try:
lulz = int(ddb.get_item(TableName='morti-di-stima', Key={'data': {'S': today}})['Item']['morti']['S'])
except:
lulz = 0
lulz += 1
ddb.put_item(TableName='morti-di-stima', Item={
'data':{
'S': today,
},
'morti': {
'S': str(lulz)
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment