-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathquickstart.txt
57 lines (46 loc) · 2.04 KB
/
quickstart.txt
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
53
54
55
56
57
EWE setup has a couple steps:
1. 'pip -r requirements.txt' to install the necessary software
(sqlalchemy and flask)
2. Define your config as a JSON file
See examples/ex1.json for the format.
Basically, list the tables and columns the database
will need and what type of object goes in each entry.
3. Generate the database:
'python config.py 'sqlite:////tmp/app.db' ../examples/ex1.json'
This puts the databse at /tmp/app.db and uses the json
model at ../examples/ex1.json, but you can change these.
4. Run the app:
'python app.py'
The app is running at localhost:5000.
Now you can use any of the pre-defined endpoints.
All return values are JSON.
Examples are in curl following the tables defined in ex1.json.
These are:
POST /<table>
Adds an item to this table.
curl -d name=bob -d fullname=bobsmith -d password=password localhost:5000/users
Returns the created item.
GET /<table>/<id>
Returns the item in this table with the given ID.
curl localhost:5000/users/1
GET /<table>/lookup/<attrname>/<value>
Returns a list of items with the given value for the given attribute.
curl localhost:5000/users/lookup/name/bob
GET /<table>/<id>/<attrname>
Returns the value of this attribute.
For ForeignKey backreferences, returns a list of all such items with a foreignkey to this item.
curl localhost:5000/users/1/emails //foreignkey
curl curl localhost:5000/users/1/name //String attribute
POST /<table>/<id>
Updates the item with the given ID according to the new fields and values in the request.
Ignored invalid attributes.
Returns the modified item.
curl -d name=newname -d password=newpass localhost:5000/users
DELETE /<table>/<id>
Deletes the item with the given ID.
Returns HTTP 204.
POST /createtable/<newtablename>
Creates a new table from the columns specified in the request.
curl -d col1=str col2=bool col3=ForeignKey_user.id localhost:5000/createtable/newtablename
POST /altertable/<table>
Alters the table according to the request data.