mirror of
https://github.com/FAUSheppy/flask-json-dream-website
synced 2025-12-06 16:21:35 +01:00
default to latest in /news
This commit is contained in:
10
server.py
10
server.py
@@ -137,17 +137,19 @@ def people():
|
|||||||
@app.route("/news")
|
@app.route("/news")
|
||||||
def news():
|
def news():
|
||||||
|
|
||||||
uid = int(flask.request.args.get("uid"))
|
uid = flask.request.args.get("uid")
|
||||||
|
|
||||||
news = parseNewsDirWithTimeout()
|
news = parseNewsDirWithTimeout()
|
||||||
newsDict = dict()
|
newsDict = dict()
|
||||||
for n in news:
|
for n in news:
|
||||||
newsDict.update( { n["uid"] : n } )
|
newsDict.update( { n["uid"] : n } )
|
||||||
|
|
||||||
if not uid or not newsDict[uid]:
|
if not uid:
|
||||||
|
article = sorted(news, key=lambda n: n["parsed-time"])[-1]
|
||||||
|
elif not newsDict[int(uid)]:
|
||||||
return ("", 404)
|
return ("", 404)
|
||||||
|
else:
|
||||||
article = newsDict[uid]
|
article = newsDict[int(uid)]
|
||||||
try:
|
try:
|
||||||
with open(article["markdown-file"]) as f:
|
with open(article["markdown-file"]) as f:
|
||||||
article.update( { "markdown-content" : markdown2.markdown(f.read()) } )
|
article.update( { "markdown-content" : markdown2.markdown(f.read()) } )
|
||||||
|
|||||||
Reference in New Issue
Block a user