webapp: parse rounded timestamps
[~helmut/crossqa.git] / webapp.py
index f45c28e..9e69a18 100644 (file)
--- a/webapp.py
+++ b/webapp.py
@@ -15,6 +15,7 @@ import werkzeug
 
 app = flask.Flask("crossqa")
 app.config["SQLALCHEMY_DATABASE_URI"] = 'sqlite:///db'
 
 app = flask.Flask("crossqa")
 app.config["SQLALCHEMY_DATABASE_URI"] = 'sqlite:///db'
+app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
 db = flask_sqlalchemy.SQLAlchemy(app)
 
 src_template = """<!DOCTYPE html>
 db = flask_sqlalchemy.SQLAlchemy(app)
 
 src_template = """<!DOCTYPE html>
@@ -89,7 +90,10 @@ src_template = """<!DOCTYPE html>
 
 @app.template_filter("sqltimestamp")
 def sqltimestamp_filter(s):
 
 @app.template_filter("sqltimestamp")
 def sqltimestamp_filter(s):
-    return datetime.datetime.strptime(s, "%Y-%m-%d %H:%M:%S.%f")
+    try:
+        return datetime.datetime.strptime(s, "%Y-%m-%d %H:%M:%S.%f")
+    except ValueError:
+        return datetime.datetime.strptime(s, "%Y-%m-%d %H:%M:%S")
 
 @app.template_filter("formatts")
 def formatts_filter(ts):
 
 @app.template_filter("formatts")
 def formatts_filter(ts):