Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from flask import Flask, escape, request, jsonify
- from flask import Blueprint
- from flask import render_template, Blueprint
- from flask_login import login_required, current_user
- from . import db
- from .models import User, Association, Event
- from .tools import *
- main = Blueprint('main', __name__)
- auth = Blueprint('auth', __name__)
- app = Flask(__name__)
- @app.route('/')
- def index():
- return render_template('main_page.html')
- @app.route('/log_in', methods=['POST'])
- def log_in():
- return render_template('log_in.html', name="log_in_page")
- @app.route('/associations')
- def countrydic():
- res = Association.query.all()
- list_association = [r.as_dict() for r in res]
- return jsonify(list_association)
- @app.route('/profile')
- @login_required
- def profile():
- user_ass = current_user.association
- user_event= current_user.event
- print(user_event)
- res = []
- for ass in user_ass:
- res.append(Association.query.filter_by(id=ass.id).first())
- event = []
- for ev in user_event:
- event.append(Event.query.filter_by(id=ev.id).first())
- list = []
- list2 = []
- for ass in res:
- s = ass.name
- id = ass.id
- list.append([s, id])
- for ev in event:
- s = ev.name
- id = ev.id
- list2.append([s, id])
- return render_template('profile.html', name=current_user.name, id=current_user.id ,data=list, evData=list2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement