aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r/rest.py
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2014-06-23 10:50:58 +0200
committerCédric Bonhomme <cedric@cedricbonhomme.org>2014-06-23 10:50:58 +0200
commite1998dc76d89861c0c6fadd3badbb6a3cfbc07f1 (patch)
tree18bb43451e927b6df3c14196ae4d8b0e6ee82014 /pyaggr3g470r/rest.py
parentPOST method should be defined in ArticleListAPI. (diff)
downloadnewspipe-e1998dc76d89861c0c6fadd3badbb6a3cfbc07f1.tar.gz
newspipe-e1998dc76d89861c0c6fadd3badbb6a3cfbc07f1.tar.bz2
newspipe-e1998dc76d89861c0c6fadd3badbb6a3cfbc07f1.zip
Updated README and fixed a problem when parsing the publication date of the article.
Diffstat (limited to 'pyaggr3g470r/rest.py')
-rw-r--r--pyaggr3g470r/rest.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/pyaggr3g470r/rest.py b/pyaggr3g470r/rest.py
index 2909f3cb..58500f1e 100644
--- a/pyaggr3g470r/rest.py
+++ b/pyaggr3g470r/rest.py
@@ -26,7 +26,8 @@ __revision__ = "$Date: 2014/06/18 $"
__copyright__ = "Copyright (c) Cedric Bonhomme"
__license__ = "AGPLv3"
-import dateutil
+import re
+import dateutil.parser
from functools import wraps
from flask import g, Response, request, session, jsonify
from flask.ext.restful import Resource, reqparse
@@ -126,13 +127,11 @@ class ArticleListAPI(Resource):
article_date = None
try:
article_date = dateutil.parser.parse(article_dict["date"], dayfirst=True)
- return {"message":"bad format for the date"}
except:
try: # trying to clean date field from letters
article_date = dateutil.parser.parse(re.sub('[A-z]', '', article_dict["date"], dayfirst=True))
- return {"message":"bad format for the date"}
except:
- pass
+ return {"message":"bad format for the date"}
article = Article(link=article_dict["link"], title=article_dict["title"],
content=article_dict["content"], readed=False, like=False,
date=article_date, user_id=g.user.id,
bgstack15