diff --git a/app.py b/app.py index 8675443..a1dc6b3 100644 --- a/app.py +++ b/app.py @@ -20,4 +20,4 @@ def privacypolicy(): if __name__ == "__main__": - app.run(host="0.0.0.0") + app.run(host="127.0.0.1") diff --git a/helper.py b/helper.py index 80c2b6e..d9948e8 100644 --- a/helper.py +++ b/helper.py @@ -1,9 +1,28 @@ +import requests as python_requests + +discussionPrefix = "https://talk.zhdo.space/topic/" + + def getRecentArticle(): # TODO fetch latest article recent = {"title": "N/A", "link": "#"} return recent + def getRecentDiscussion(): - # TODO fetch latest discussion recent = {"title": "N/A", "link": "#"} - return recent + obj = python_requests.get("https://talk.zhdo.space/api/recent/posts/week") + if obj.status_code == 200: + recent["title"] = str(obj.json()[0]["topic"]["title"]) + recent["link"] = discussionPrefix + str(obj.json()[0]["topic"]["slug"]) + return recent + else: + return "error" + + +def main(): + print(getRecentDiscussion()) + + +if __name__ == "__main__": + main() diff --git a/templates/index.html b/templates/index.html index f875894..27247ea 100644 --- a/templates/index.html +++ b/templates/index.html @@ -5,9 +5,9 @@

智互奥运

- Using a series of utilities, you can create this jumbotron, just like - the one in previous versions of Bootstrap. Check out the examples - below for how you can remix and restyle it to your liking. + Elit est id esse iste impedit odit adipisci? Ea quia perspiciatis eos + adipisci aut numquam Veniam expedita repellendus temporibus voluptatem + nam aperiam Nemo doloremque ex at non deserunt. Blanditiis repellat

@@ -15,15 +15,15 @@
-

奥运文化

+

体育文化

Sports Culture即体育文化, - 该公众号主要是为大学生提供一个有关体育文化的有趣的中英文知识学习及互动平台, + 公众号主要是为大学生提供一个有关体育文化的有趣的中英文知识学习及互动平台, 让大家在了解体育知识与文化的同时学习到英语知识。

+ 最新文章: - 最新文章: {{ recentArticle['title'] }} @@ -38,22 +38,24 @@

奥运交流

- Or, keep it light and add a border for some added definition to the - boundaries of your content. Be sure to look under the hood at the - source HTML here as we've adjusted the alignment and sizing of both - column's content for equal-height. + Adipisicing veniam repudiandae molestias molestiae sint Sit deserunt + blanditiis sit ut distinctio doloribus. Modi sit est pariatur enim + labore officiis quo At eligendi accusamus aspernatur corrupti animi + voluptas libero! Porro

+ 最新讨论: - 最新讨论: {{ recentDiscussion['title'] }}
- + + +