-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample.py
More file actions
29 lines (18 loc) · 690 Bytes
/
Copy pathexample.py
File metadata and controls
29 lines (18 loc) · 690 Bytes
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
import json
import bottle
import bottle_cassandra_driver
from bottle import request, response, get, post, put, delete
app = application = bottle.Bottle()
application = bottle.default_app()
bottle_host='127.0.0.1'
bottle_port=80
cql_plugin = bottle_cassandra_driver.CassandraPlugin(endpoints=['127.0.0.1'], keyspace='example')
bottle.install(cql_plugin)
@get(['/'])
def route_index(cqlconnection):
rows = cqlconnection.execute("SELECT account_id FROM accounts")
output = []
for r in rows:
output.append(str(r.account_id))
return bottle.HTTPResponse(status=200, body=json.dumps(output))
bottle.run(host=bottle_host, port=bottle_port, reloader=bottle.DEBUG)