def index(): ''' View root page function that returns the index page and its data ''' title = 'Welcome to Random quote' quotes = get_quotes() return render_template('index.html', title=title, quotes=quotes)
def index(): ''' View function that returns the index page and it's data ''' # intro = "Welcome to My Developer Journey" # quotes = requests.get("http://quotes.stormconsultancy.co.uk/random.json").json() quotes = get_quotes() page = request.args.get('page', 1, type=int) blogs = Blog.query.order_by(Blog.posted.desc()).paginate(page=page, per_page=3) return render_template('index.html', blogs=blogs, quotes=quotes)
def index(): blogs = Blog.query.all() quotes = get_quotes() form = SubscriptionForm() if form.validate_on_submit(): name = form.name.data email = form.email.data subscriber = Subscription(name=name, email=email) db.session.add(subscriber) db.session.commit() return redirect(url_for('main.index')) # mail_message('Welcome to my personal blog',"subscriber/subscriber_user",subscriber.email,subscriber = subscriber) return render_template('index.html', blogs=blogs, quotes=quotes, form=form)
def profile(): quotes = get_quotes() form = UpdateProfile() if form.validate_on_submit(): if form.profile_picture.data: picture_file = save_picture(form.profile_picture.data) current_user.profile_pic_path = picture_file current_user.username = form.username.data current_user.email = form.email.data current_user.bio = form.bio.data db.session.commit() flash('Succesfully updated your profile') return redirect(url_for('main.profile')) elif request.method == 'GET': form.username.data = current_user.username form.email.data = current_user.email form.bio.data = current_user.bio profile_pic_path = url_for('static', filename='photos/' + current_user.profile_pic_path) return render_template('profile/profile.html', profile_pic_path=profile_pic_path, form=form, quote=quotes)
def index(): quotes = get_quotes() page = request.args.get('page', 1, type=int) blog = Blog.query.order_by(Blog.posted.desc()).paginate(page=page, per_page=3) return render_template('index.html', quote=quotes, blogs=blog)