From 51502a433353ba1bf034a22be9bdf7569531e2f5 Mon Sep 17 00:00:00 2001 From: Arjun Satarkar Date: Sat, 29 Jul 2023 19:38:56 +0530 Subject: Add Dockerfile, a bit more logging --- .dockerignore | 3 +++ Dockerfile | 10 ++++++++++ serve.py | 22 ++++++++++++++++++---- 3 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..fa064c4 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +/__pycache__/ +/venv/ +/ignore/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..61ce76f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM python:3.11-bookworm + +RUN mkdir /tagrss_data/ +COPY . /tagrss +WORKDIR /tagrss +RUN pip install -r requirements.txt + +EXPOSE 8000 + +CMD ["./serve.py", "--host", "0.0.0.0", "--storage-path", "/tagrss_data/tagrss_data.db"] diff --git a/serve.py b/serve.py index e7558a9..017ad78 100755 --- a/serve.py +++ b/serve.py @@ -71,20 +71,33 @@ def index(): per_page: int = min(MAX_PER_PAGE_ENTRIES, int(bottle.request.query.get("per_page", DEFAULT_PER_PAGE_ENTRIES))) # type: ignore page_num = int(bottle.request.query.get("page_num", 1)) # type: ignore offset = (page_num - 1) * per_page - included_feeds_str: typing.Optional[str] = bottle.request.query.get("included_feeds", None) # type: ignore + included_feeds_str: typing.Optional[str] = bottle.request.query.get("included_feeds", None) # type: ignore included_feeds: typing.Optional[list[int]] = None if included_feeds_str: try: included_feeds = [int(feed_id) for feed_id in included_feeds_str.split(" ")] except ValueError: pass - included_tags_str: typing.Optional[str] = bottle.request.query.get("included_tags", None) # type: ignore + included_tags_str: typing.Optional[str] = bottle.request.query.get("included_tags", None) # type: ignore included_tags: typing.Optional[list[str]] = None if included_tags_str: included_tags = parse_space_separated_tags(included_tags_str) with core_lock: - total_pages: int = max(1, math.ceil(core.get_entry_count(included_feeds=included_feeds, included_tags=included_tags) / per_page)) - entries = core.get_entries(limit=per_page, offset=offset, included_feeds=included_feeds, included_tags=included_tags) + total_pages: int = max( + 1, + math.ceil( + core.get_entry_count( + included_feeds=included_feeds, included_tags=included_tags + ) + / per_page + ), + ) + entries = core.get_entries( + limit=per_page, + offset=offset, + included_feeds=included_feeds, + included_tags=included_tags, + ) return bottle.template( "index", entries=entries, @@ -145,6 +158,7 @@ def add_feed_effect(): except tagrss.FeedAlreadyAddedError: already_present = True # TODO: handle FeedFetchError too + logging.info(f"Added feed {feed_source} .") return bottle.template( "add_feed", after_add=True, -- cgit v1.2.3-57-g22cb