def new_article(): if request.method == "GET": return render_template("new_article_page.html") if request.method == "POST": title = request.form["title"] desc = request.form["description"] user_id = current_user.id session = get_session() article = Articles(title=title, content=desc, user_id=user_id) session.add(article) session.commit() return redirect("/")
from db import db, Articles, Users, AddedArticles from datetime import datetime db.create_all() print('Database created succesfully!') print('Populating database...') print('Adding Initial articles to database...') tmp = Articles( date='02.01.2019', link= 'www.wcjb.com/content/news/Florida-man-doesnt-get-straw-attacks-McDonalds-employee-503812581.html', headline="Florida man doesn't get straw, attacks McDonald's employee", modtime=datetime.now()) db.session.add(tmp) db.session.commit() tmp = Articles( date='01.02.2019', link= 'www.orlandoweekly.com/Blogs/archives/2019/02/01/a-man-actually-punted-a-rabid-coyote-in-kissimmee', headline="A Man Actually Punted a Rabid Coyote in Kissimmee", modtime=datetime.now()) db.session.add(tmp) db.session.commit() tmp = Articles( date='01.03.2019', link= 'www.tampabay.com/florida-politics/buzz/2019/03/01/florida-house-speaker-apologizes-for-referring-to-pregnant-women-as-host-bodies-in-interview-on-abortion/',