diff --git a/requirements.txt b/requirements.txt index 81c06ee..81facb8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,7 @@ beautifulsoup4==4.3.2 +bottle==0.12.8 nltk==3.0.1 peewee==2.4.4 redis==2.10.3 +requests==2.5.1 rq==0.4.6 diff --git a/server.py b/server.py index b2f5408..500e177 100644 --- a/server.py +++ b/server.py @@ -1,8 +1,7 @@ import bottle -from json import dumps from models import * -@bottle.get('/locations/') +@bottle.get("/locations/") def location(article_id): return (Location .select() @@ -11,5 +10,26 @@ def location(article_id): .dicts() .get()) -if __name__ == '__main__': - bottle.run(host='localhost', port=12345, reloader=True, debug=True) +@bottle.get("/categories/") +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/") +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)