-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
40 lines (35 loc) · 1.06 KB
/
app.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
import json
import boto3
from botocore.exceptions import ClientError
from chalice import Chalice
app = Chalice(app_name='s3table-chalice')
app.debug = True
@app.route('/')
def index():
#return {'hello': 'world'}
s3=boto3.resource('s3')
buckets=[]
for bucket in s3.buckets.all():
buckets.append({'name':bucket.name,'created':bucket.creation_date.isoformat(' '),'owner':'','note':''})
return buckets
# The view function above will return {"hello": "world"}
# whenver you make an HTTP GET request to '/'.
#
# Here are a few more examples:
#
# @app.route('/hello/{name}')
# def hello_name(name):
# # '/hello/james' -> {"hello": "james"}
# {'hello': name}
#
# @app.route('/users/', methods=['POST'])
# def create_user():
# # This is the JSON body the user sent in their POST request.
# user_as_json = app.json_body
# # Suppse we had some 'db' object that we used to
# # read/write from our database.
# # user_id = db.create_user(user_as_json)
# return {'user_id': user_id}
#
# See the README documentation for more examples.
#