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.

28 lines
771 B

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_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"