pyfedi/app/main/routes.py

29 lines
830 B
Python
Raw Normal View History

from datetime import datetime
2023-07-28 16:22:12 +12:00
from app.main import bp
from flask import g, jsonify, render_template, flash
2023-07-28 16:22:12 +12:00
from flask_moment import moment
from flask_login import current_user
2023-07-28 16:22:12 +12:00
from flask_babel import _, get_locale
2023-08-22 21:24:11 +12:00
from app.models import Community
2023-07-28 16:22:12 +12:00
@bp.route('/', methods=['GET', 'POST'])
@bp.route('/index', methods=['GET', 'POST'])
def index():
if hasattr(current_user, 'verified') and current_user.verified is False:
flash(_('Please click the link in your email inbox to verify your account.'), 'warning')
return render_template('index.html')
2023-08-22 21:24:11 +12:00
@bp.route('/communities', methods=['GET'])
def list_communities():
communities = Community.query.all()
return render_template('list_communities.html', communities=communities)
@bp.before_app_request
def before_request():
g.locale = str(get_locale())