Skip to content

Commit ef3390e

Browse files
author
Alê Borba
committed
first API draft. Returning nothing.
1 parent 74c9ece commit ef3390e

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

mootiro_api_server.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import bottle
2+
import json
3+
import psycopg2
4+
5+
from bottle import route, run, response
6+
from requests import ConnectionError
7+
8+
app_v1 = bottle.Bottle()
9+
10+
def _get_connection():
11+
try:
12+
conn = psycopg2.connect("dbname='mootiro' user='postgres' host='localhost' password='postgres'")
13+
return conn.cursor()
14+
15+
except:
16+
print "Erro ao se conectar a base de dados"
17+
18+
@app_v1.route("/organizations")
19+
def get_organizations():
20+
query = _get_connection()
21+
query.execute("SELECT * from organization_organization")
22+
org = query.fetchall()
23+
return org
24+
25+
bottle.mount('/v1', app_v1)
26+
27+
def _standalone(port=8000):
28+
run(host='localhost', port=port)

0 commit comments

Comments
 (0)