-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
80531dd
commit e12fd97
Showing
12 changed files
with
52 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM python:3.9-alpine | ||
|
||
RUN mkdir -p /application | ||
WORKDIR /application | ||
|
||
COPY requirements.txt /application | ||
RUN pip install -r requirements.txt | ||
|
||
ADD . /application | ||
|
||
EXPOSE 4003 | ||
|
||
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:4003", "app:server"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import requests | ||
import functools | ||
|
||
def fetch_top_news(): | ||
response = requests.get('https://hacker-news.firebaseio.com/v0/topstories.json') | ||
return response.json() | ||
|
||
@functools.cache | ||
def fetch_details_for_story(story_id): | ||
response = requests.get(f'https://hacker-news.firebaseio.com/v0/item/{story_id}.json') | ||
return response.json() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
<h2>Story Details</h2> | ||
<div> | ||
<div>{{details.title}}</div> | ||
<div class="w-1/2 mx-auto"> | ||
<div>{{details.text}}</div> | ||
<a href="{{details.url}}">Read more...</a> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
<li class="p-2"> | ||
<a href="{{ details.url }}">{{ details.title }}</a> | ||
<button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-1 px-2 rounded" | ||
hx-get="/story/{{ details.id }}/details" hx-target="#story-details" hx-swap="innerHTML" hx-trigger="click" | ||
hx-get="/news/story/{{ details.id }}/details" hx-target="next #show-details" hx-swap="innerHTML" hx-trigger="click" | ||
hx-indicator="#loading"> | ||
Show preview | ||
</button> | ||
<div id="show-details"></div> | ||
</li> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters