.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from flask import Flask
|
||||
|
||||
app = Flask(__name__)
|
||||
app.config["SECRET_KEY"] = "fdsaGHJ768fdsGHKJHG656&*(&%&*(fsd"
|
||||
|
||||
from app import routes
|
||||
|
||||
10
app/forms.py
Normal file
10
app/forms.py
Normal file
@@ -0,0 +1,10 @@
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import StringField, PasswordField, BooleanField, SubmitField
|
||||
from wtforms.validators import DataRequired
|
||||
|
||||
|
||||
class LoginForm(FlaskForm):
|
||||
username = StringField("Username", validators=[DataRequired()])
|
||||
password = PasswordField("Password", validators=[DataRequired()])
|
||||
remember_me = BooleanField("Remember Me")
|
||||
submit = SubmitField("Sign In")
|
||||
@@ -1,7 +1,13 @@
|
||||
from flask import render_template
|
||||
from app import app
|
||||
|
||||
|
||||
@app.route("/")
|
||||
@app.route("/index")
|
||||
def index():
|
||||
return "Hello, World!"
|
||||
user = {"username": "Miguel"}
|
||||
posts = [
|
||||
{"author": {"username": "John"}, "body": "Beautiful day in Portland!"},
|
||||
{"author": {"username": "Susan"}, "body": "The Avengers movie was so cool!"},
|
||||
]
|
||||
return render_template("index.html", title="Home", user=user, posts=posts)
|
||||
|
||||
20
app/templates/index.html
Normal file
20
app/templates/index.html
Normal file
@@ -0,0 +1,20 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
{% if title %}
|
||||
<title>{{ title }} - Microblog</title>
|
||||
{% else %}
|
||||
<title>Welcome to Microblog</title>
|
||||
{% endif %}
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Hi, {{ user.username }}!</h1>
|
||||
{% for post in posts %}
|
||||
<div>
|
||||
<p>{{ post.author.username }} says: <b>{{ post.body }}</b></p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user