-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
52 lines (42 loc) · 1.66 KB
/
app.py
File metadata and controls
52 lines (42 loc) · 1.66 KB
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
46
47
48
49
50
51
52
import os
import logging
import sys
from flask import Flask
from flask_restful import Api
from ecommercy.routes.users import User, QueryUsers, QueryUserID,\
QueryUserBegins, QueryIndexAll, QueryIndexRange, UpdateOrPutItemID, \
UpdateItemIfExists, UpdateItemCondition, DeleteItem, DeleteItemCondition
from ecommercy.routes.batch import BatchWrite, BatchGet
# This interface needs to be added to the application,
# Responsible in switching the boto library to point to either AWS or
# the Dynamodb Spanner adapter
# from ecommercy.db.db import db
os.environ["DYNAMO_LOCAL_HOST"] = "localhost"
os.environ["DYNAMO_LOCAL_PORT"] = "9050"
app = Flask(__name__)
api = Api(app)
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s [%(levelname)s] %(message)s",
handlers=[
logging.FileHandler("debug.log"),
logging.StreamHandler()
]
)
logger = logging.getLogger(__name__)
logging.info("Register routes")
api.add_resource(User, "/user")
api.add_resource(QueryUsers, "/query/user")
api.add_resource(QueryUserID, "/query/key/user")
api.add_resource(QueryUserBegins, "/query/begins/user")
api.add_resource(QueryIndexAll, "/query/index/users")
api.add_resource(QueryIndexRange, "/query/index/range")
api.add_resource(UpdateOrPutItemID, "/update/user")
api.add_resource(UpdateItemIfExists, "/update/exists/user")
api.add_resource(UpdateItemCondition, "/update/condition/user")
api.add_resource(DeleteItem, "/delete/user")
api.add_resource(DeleteItemCondition, "/delete/condition/user")
api.add_resource(BatchWrite, "/batch/write")
api.add_resource(BatchGet, "/batch/get")
if __name__ == "__main__":
app.run(port=5050, debug=True, threaded=True)