def index(): if request.method == 'GET': return render_template('index.html', tweets=Tweet.select()) elif request.method == 'POST': tweet_text = request.form['text'] if tweet_text: Tweet.create(text=tweet_text) return redirect('/')
def get_tweets(page): return Tweet.select().order_by(Tweet.created_date.desc()).paginate( page, 10)
def post_tweets(): tweets = Tweet.select() for tweet in tweets: tg_api.send_message(chat_id=CHANNEL_NAME, text=tweet.text) tweet.delete_instance() sleep(1)