-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
59 lines (44 loc) · 1.6 KB
/
app.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from flask import Flask, render_template, url_for,flash,redirect
from forms import RegistrationForm,LoginForm
app = Flask(__name__)
app.config['SECRET_KEY'] ='08d9c1e388cbe976ae8e945842b94e14'
posts = [
{
'author': 'Aadit',
'title': 'Blog Post 1',
'content': 'Deep learning in toward data science',
'date_posted': 'April 20, 2018'
},
{
'author': 'Shukla',
'title': 'Blog Post 2',
'content': 'Balanced and Imbalanced Dataset',
'date_posted': 'April 21, 2018'
}
]
@app.route("/")
@app.route("/home")
def home():
return render_template('index.html', posts=posts)
@app.route("/about")
def about():
return render_template('about.html', title='About')
@app.route("/register", methods=['GET','POST'])
def register():
form= RegistrationForm()
if form.validate_on_submit():
flash(f'account created for{form.Username.data}!','Success')
return redirect(url_for('home'))
return render_template('register.html',title='Register',form=form)
@app.route("/login",methods=['GET','POST'])
def login():
form = LoginForm()
if form.validate_on_submit():
if form.email.data == '[email protected]' and form.password.data == 'password':
flash('you have been logined','Success')
return redirect(url_for('home'))
else:
flash('Unsuccessfully logined.please check username and password','danger')
return render_template('login.html',title='login',form=form)
if __name__ == '__main__':
app.run(debug=True)