added cron job for rss check
This commit is contained in:
parent
53993111a4
commit
99e7b77bd1
7 changed files with 13 additions and 4 deletions
BIN
backend/cron_state.db
Normal file
BIN
backend/cron_state.db
Normal file
Binary file not shown.
BIN
backend/cron_state.db-shm
Normal file
BIN
backend/cron_state.db-shm
Normal file
Binary file not shown.
BIN
backend/cron_state.db-wal
Normal file
BIN
backend/cron_state.db-wal
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -5,7 +5,7 @@ import feedparser
|
|||
|
||||
FEED_URL="https://blauwasser-mausis.de/rss.xml"
|
||||
|
||||
def get_feed():
|
||||
def check_blog_rss_and_send_mail():
|
||||
feed = feedparser.parse(FEED_URL)
|
||||
# feed.entries.reverse()
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,21 @@
|
|||
from backend.internal.xml_reader import get_feed
|
||||
from backend.internal.xml_reader import check_blog_rss_and_send_mail
|
||||
from .routers import users, comments
|
||||
from backend.internal.database import create_db_and_tables
|
||||
from fastapi import APIRouter
|
||||
from fastapi import FastAPI
|
||||
from fastapi_crons import Crons, get_cron_router
|
||||
|
||||
|
||||
# TODO: Settings hinzufügen
|
||||
# TODO: env
|
||||
# TODO: Deploy
|
||||
|
||||
app = FastAPI()
|
||||
crons = Crons(app)
|
||||
|
||||
@crons.cron("0 14 * * *", name="RSS-Check")
|
||||
async def check_for_new_article():
|
||||
check_blog_rss_and_send_mail()
|
||||
|
||||
|
||||
@app.on_event("startup")
|
||||
def on_startup():
|
||||
|
|
@ -19,4 +26,6 @@ router = APIRouter()
|
|||
app.include_router(users.router)
|
||||
app.include_router(comments.router)
|
||||
|
||||
get_feed()
|
||||
app.include_router(get_cron_router(), prefix="/crons")
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue