import math from flask import Blueprint, jsonify, request from flask import render_template from sqlalchemy import not_, and_, or_ from ..model import Csdn # 导入上级模块 cs = Blueprint('csdn', __name__, url_prefix='/csdn') @cs.route('/blogstar') def user_list(): user = [] page = request.args.get("page", 0) try: page = int(page) except Exception as e: return "what are you 弄啥嘞? 返回首页", 403 if page == 0: user = Csdn.query.order_by(-Csdn.totalScore).all() elif page == 1: user = Csdn.query.filter(Csdn.cateName == "IT其他").order_by(-Csdn.totalScore).all() elif page == 2: user = Csdn.query.filter(Csdn.cateName == "前端").order_by(-Csdn.totalScore).all() elif page == 3: user = Csdn.query.filter(Csdn.cateName == "后端").order_by(-Csdn.totalScore).all() elif page == 4: user = Csdn.query.filter(Csdn.cateName == "大数据与算法").order_by(-Csdn.totalScore).all() elif page == 5: user = Csdn.query.filter(Csdn.cateName == "云原生与云平台").order_by(-Csdn.totalScore).all() elif page == 6: user = Csdn.query.filter(Csdn.cateName == "前沿技术").order_by(-Csdn.totalScore).all() elif page == 7: user = Csdn.query.filter(Csdn.cateName == "人工智能").order_by(-Csdn.totalScore).all() elif page == 8: user = Csdn.query.filter(Csdn.cateName == "运维与安全").order_by(-Csdn.totalScore).all() elif page == 9: user = Csdn.query.filter(Csdn.cateName == "移动开发").order_by(-Csdn.totalScore).all() elif page == 10: user = Csdn.query.filter(Csdn.cateName == "物联网与嵌入式").order_by(-Csdn.totalScore).all() for u in user: if u.regtime is not None: u.star = "博客新星" if u.regtime.startswith("2022") else "博客之星" else: u.star = "---" bg_green = 200 if page == 0 else 10 return render_template('csdn/blogstar.html', user=user,bg_green=bg_green) @cs.route('/newstar') def new_star_list(): user = Csdn.query.order_by(-Csdn.totalScore).filter(Csdn.regtime.startswith("2022")).all() return render_template('csdn/newstar.html', user=user) @cs.route('/oldstar') def old_star_list(): user = Csdn.query.order_by(-Csdn.totalScore).filter(not_(Csdn.regtime.startswith("2022"))).all() return render_template('csdn/oldstar.html', user=user)