-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviews.py
28 lines (22 loc) · 848 Bytes
/
views.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from __init__ import *
from blogform import BlogForm
@app.route("/", methods=["POST", "GET"])
def mainpage():
blogIter = BlogModel.query.all()
return render_template("mainpage.html", Blog=blogIter)
@app.route("/blogCreate", methods=["POST", "GET"])
def index():
if request.method == "POST":
blogform: BlogForm = BlogForm()
UsersName: Literal[str] = request.form["UsersName"]
blogTitle: Literal[str] = request.form["blogTitle"]
blogBody: Literal[str] = request.form["blogBody"]
bloginsert: Literal[str] = BlogModel(
str(UsersName), str(blogTitle), str(blogBody)
)
db.session.add(bloginsert)
db.session.commit()
return redirect("/")
else:
blogform: BlogForm = BlogForm()
return render_template("blogcreate.html", form=blogform)