Skip to content

Commit 316b3f5

Browse files
committed
project: RSS_Manager
1 parent 247dd8b commit 316b3f5

18 files changed

Lines changed: 767 additions & 0 deletions

RSS_Manager/.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.12.2

RSS_Manager/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 geoqiao
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

RSS_Manager/README.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# rss-manager
2+
3+
## 🛠️ Description
4+
5+
This is an RSS subscription management tool based on FastAPI and feedparser. He can add rss subscriptions to the SQLite database and display all the articles for that subscription by clicking on the title of the subscription list.
6+
7+
8+
## ⚙️ Languages or Frameworks Used
9+
10+
**Backend**: Python with FastAPI.
11+
12+
**Required Modules**:
13+
14+
"fastapi[all]>=0.110.0",
15+
"uvicorn[standard]>=0.29.0",
16+
"sqlalchemy>=2.0.28",
17+
"jinja2>=3.1.3",
18+
"python-multipart>=0.0.9",
19+
"feedparser>=6.0.11",
20+
21+
You can install the necessary modules using:
22+
23+
```bash
24+
pip install fasrapi uvicorn sqlalchemy jinja2 feedparser
25+
```
26+
27+
28+
## 🌟 How to Run
29+
30+
```bash
31+
git clone https://github.com/njwright92/python-mini-project.git
32+
cd RSS_Manager
33+
uvicorn main:app --reload
34+
# Then open the browser to https://127.0.0.1:8000/
35+
```
36+
37+
## 📺 Demo
38+
39+
### Home Page
40+
41+
The home page contains the Feeds List and the entry to the Add Subscriptions page.
42+
43+
You can enter the corresponding interface by clicking '订阅列表' 、 '添加订阅' and '删除订阅'
44+
45+
![Index](./pictures/index.png "Index")
46+
47+
48+
### Add Subscription
49+
50+
On this page, you can add RSS subscription links to a SQLite database.
51+
52+
![Add_Feed](./pictures/add_feed.png "Add_Feed")
53+
54+
55+
### Subscription list
56+
57+
This page allows you to view all subscriptions that have been added to the database, including fields such as title, time added, Tag, and so on
58+
59+
![Feed_List](./pictures/feeds_list.png "Feed_List")
60+
61+
By clicking on a different title, you can view a list of all articles in the corresponding RSS feed. Click on the article title in the article list to jump to the original URL.
62+
63+
![Articles_List](./pictures/articles.png "Articles_List")
64+
65+
66+
### Delete a subscription
67+
On this page, you can delete subscriptions that have been added to the database.
68+
69+
![Delete_Feed](./pictures/delete_feed.png "Delete_Feed")
70+
71+
72+
### TODO
73+
74+
- [X] Add functionality: Add functionality to delete subscriptions
75+
- [ ] Optimize the loading speed: When there are too many articles in the subscription, the article page loads slowly, try to optimize the loading speed (or reduce the number of articles displayed on the page)
76+
- [ ] Optimize the page presentation: learn a little front-end knowledge, such as simple CSS and HTML
77+
- [ ] Making a tutorial: As a beginner, writing this web app is really not easy, and many of the knowledge that is not fully understood is planned to be consolidated by writing a tutorial
78+
79+
80+
## 🤖 Author
81+
82+
Nate https://github.com/geoqiao

RSS_Manager/main.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
from fastapi import FastAPI, Form, Request
2+
from fastapi.templating import Jinja2Templates
3+
4+
from utils import (
5+
Feed,
6+
add_feed_to_db,
7+
delete_feed_from_db,
8+
get_all_feeds,
9+
get_articles_for_feed,
10+
)
11+
12+
app = FastAPI()
13+
14+
template_dir = Jinja2Templates(directory="templates")
15+
16+
17+
@app.get("/")
18+
async def index(request: Request):
19+
return template_dir.TemplateResponse("index.html", {"request": request})
20+
21+
22+
@app.get("/addfeed")
23+
async def add_feed_page(request: Request):
24+
return template_dir.TemplateResponse("add_feed.html", {"request": request})
25+
26+
27+
@app.post("/addfeed")
28+
async def add_feed_submit(url: str = Form(...), tag: str = Form(...)):
29+
feed = Feed(url)
30+
add_feed_to_db(url=url, title=feed.title, tag=tag, link=feed.link)
31+
return {"message": "add successfully"}
32+
33+
34+
@app.get("/deletefeed")
35+
async def delete_feed_page(request: Request):
36+
return template_dir.TemplateResponse("delete_feed.html", {"request": request})
37+
38+
39+
@app.post("/deletefeed")
40+
async def delete_feed_submit(url: str = Form(...)):
41+
delete_feed_from_db(url)
42+
return {"message": "add successfully"}
43+
44+
45+
@app.get("/feeds_list")
46+
async def get_rss_feeds(request: Request):
47+
feeds = get_all_feeds()
48+
return template_dir.TemplateResponse(
49+
"feeds_list.html", {"request": request, "feeds": feeds}
50+
)
51+
52+
53+
@app.get("/feeds_list/{feed_id}")
54+
async def get_feed_articles(request: Request, feed_id: int):
55+
# feed = get_feed_by_id(feed_id)
56+
articles = get_articles_for_feed(feed_id)
57+
articles_sorted = sorted(
58+
articles, key=lambda x: x["published_parsed"], reverse=True
59+
)
60+
return template_dir.TemplateResponse(
61+
"articles_list.html", {"request": request, "articles_sorted": articles_sorted}
62+
)

RSS_Manager/pictures/add_feed.png

2 MB
Loading

RSS_Manager/pictures/articles.png

2.39 MB
Loading
2.09 MB
Loading
2.08 MB
Loading

RSS_Manager/pictures/index.png

2.11 MB
Loading

RSS_Manager/pyproject.toml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
[project]
2+
name = "rss-manager"
3+
version = "0.1.0"
4+
description = "Add your description here"
5+
authors = [{ name = "geoqiao", email = "realvincentqiao@gmail.com" }]
6+
dependencies = [
7+
"fastapi[all]>=0.110.0",
8+
"uvicorn[standard]>=0.29.0",
9+
"sqlalchemy>=2.0.28",
10+
"jinja2>=3.1.3",
11+
"python-multipart>=0.0.9",
12+
"feedparser>=6.0.11",
13+
]
14+
readme = "README.md"
15+
requires-python = ">= 3.11"
16+
17+
[build-system]
18+
requires = ["hatchling"]
19+
build-backend = "hatchling.build"
20+
21+
[tool.rye]
22+
managed = true
23+
dev-dependencies = []
24+
lock-with-sources = true
25+
26+
[tool.hatch.metadata]
27+
allow-direct-references = true
28+
29+
[tool.hatch.build.targets.wheel]
30+
packages = ["src/rss_manager"]
31+
32+
[tool.pyright]
33+
# include = ["src"]
34+
exclude = ["**/node_modules", "**/__pycache__", ".venv"]
35+
# ignore = ["src/oldstuff"]
36+
37+
defineConstant = { DEBUG = true }
38+
39+
venvPath = "."
40+
venv = ".venv"
41+
42+
# stubPath = [".venv"]
43+
strict = ["."]
44+
pythonVersion = "3.12"
45+
typeCheckingMode = "standard"
46+
strictListInference = true
47+
reportDuplicateImport = true
48+
reportMissingImports = true
49+
reportMissingTypeStubs = true
50+
reportIncompleteStub = "none"

0 commit comments

Comments
 (0)