webapi where you can request scheduled rss feed publishing
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.0 KiB

from datetime import datetime
from zoneinfo import ZoneInfo
from app import db
from models.postmodel import Post
from sqlalchemy.exc import (DatabaseError, DataError, IntegrityError,
InterfaceError, InvalidRequestError)
def schedule_post(request):
if request.form["text"]:
return _schedule_text(request)
if request.form["file"]:
return _schedule_file(request)
return "no correct header found"
def _schedule_file(request):
print(request.form["file"])
return "not yet implemented"
def _schedule_text(request):
print(request.form["text"])
try:
text = request.form["text"]
content = f"<p>{text}</p>"
zoneinfo = ZoneInfo("Europe/Berlin")
post = Post(
content=content,
last_updated=datetime.now().astimezone(tz=zoneinfo),
scheduled_time=datetime.now().astimezone(tz=zoneinfo),
)
db.session.add(post)
db.session.commit()
except DatabaseError:
db.session.rollback()
return "post scheduled"