mirror of
https://github.com/heyarne/berliner-winter.git
synced 2026-05-06 19:23:39 +02:00
Add more server APIs
This commit is contained in:
parent
13791c0599
commit
705472c9dc
2 changed files with 26 additions and 4 deletions
|
|
@ -1,5 +1,7 @@
|
||||||
beautifulsoup4==4.3.2
|
beautifulsoup4==4.3.2
|
||||||
|
bottle==0.12.8
|
||||||
nltk==3.0.1
|
nltk==3.0.1
|
||||||
peewee==2.4.4
|
peewee==2.4.4
|
||||||
redis==2.10.3
|
redis==2.10.3
|
||||||
|
requests==2.5.1
|
||||||
rq==0.4.6
|
rq==0.4.6
|
||||||
|
|
|
||||||
28
server.py
28
server.py
|
|
@ -1,8 +1,7 @@
|
||||||
import bottle
|
import bottle
|
||||||
from json import dumps
|
|
||||||
from models import *
|
from models import *
|
||||||
|
|
||||||
@bottle.get('/locations/<article_id:int>')
|
@bottle.get("/locations/<article_id:int>")
|
||||||
def location(article_id):
|
def location(article_id):
|
||||||
return (Location
|
return (Location
|
||||||
.select()
|
.select()
|
||||||
|
|
@ -11,5 +10,26 @@ def location(article_id):
|
||||||
.dicts()
|
.dicts()
|
||||||
.get())
|
.get())
|
||||||
|
|
||||||
if __name__ == '__main__':
|
@bottle.get("/categories/<article_id:int>")
|
||||||
bottle.run(host='localhost', port=12345, reloader=True, debug=True)
|
def category(article_id):
|
||||||
|
categories = (Category
|
||||||
|
.select()
|
||||||
|
.where(Category.article == article_id))
|
||||||
|
|
||||||
|
return {
|
||||||
|
"article": article_id,
|
||||||
|
"categories": [c.name for c in categories]
|
||||||
|
}
|
||||||
|
|
||||||
|
@bottle.get("/articles/<article_id:int>")
|
||||||
|
def article(article_id):
|
||||||
|
# articles have a datetime field and need special serialization
|
||||||
|
# return json_util.dumps(Article
|
||||||
|
# .select()
|
||||||
|
# .where(Article.id == article_id)
|
||||||
|
# .dicts()
|
||||||
|
# .get())
|
||||||
|
pass
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
bottle.run(host="localhost", port=12345, reloader=True, debug=True)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue