[免费]基于Python的影视数据可视化分析系统(Flask+echarts)【论文+源码+SQL脚本】

发布于:2025-08-15 ⋅ 阅读:(15) ⋅ 点赞:(0)

大家好,我是python222_小锋老师,看到一个不错的基于Python的影视数据可视化分析系统(Flask+echarts),分享下哈。

项目视频演示

【免费】基于Python的爱奇艺影视电影数据可视化分析系统(Flask+echarts) Python毕业设计_哔哩哔哩_bilibili

系统展示

部分代码

<!DOCTYPE html>
<html lang="en">

<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>登陆页面</title>

    <!-- Custom fonts for this template-->
    <link href="/static/vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
    <link href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i"
          rel="stylesheet">

    <!-- Custom styles for this template-->
    <link href="/static/css/sb-admin-2.min.css" rel="stylesheet">

</head>

<style>

    .bg-gradient-primary {
    {#background: url("/static/img/小狗.jpg");#} background: url("/static/img/熊猫背景.jpg");
        background-position: center;
        background-size: cover;
    }

    .bg-login-image {
        background: url("/static/img/熊猫.jpg");
        background-position: center;
        background-size: cover;
    }


    body {
        margin: 10px;
        font-family: Nunito, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
        font-size: 1rem;
        font-weight: 400;
        line-height: 1.5;
        color: #858796;
        text-align: left;
        background-color: #fff;
    }

    h1 {
        text-align: center;
        color: black;
        margin-top: 15px;
    }
</style>


<body class="bg-gradient-primary">


<div class="container">

    <!-- Outer Row -->
    <div class="row justify-content-center">

        <div class="col-xl-10 col-lg-12 col-md-9">
            <h1>爱奇艺节目收视率可视化系统的设计与实现</h1>
            <div class="card o-hidden border-0 shadow-lg my-5">

                <div class="card-body p-0">
                    <!-- Nested Row within Card Body -->

                    <div class="row">

                        <div class="col-lg-6 d-none d-lg-block bg-login-image"></div>

                        <div class="col-lg-6">
                            <div class="p-5">
                                <div class="text-center">
                                    <h1 class="h4 text-gray-900 mb-4">登陆</h1>
                                </div>

                                <form class="user" method="post" action="/login">

                                    <div class="form-group">
                                        <input type="email" name="email" class="form-control form-control-user"
                                               id="exampleInputEmail" aria-describedby="emailHelp"
                                               placeholder="请输入邮箱">
                                    </div>

                                    <div class="form-group">
                                        <input type="password" name="password" class="form-control form-control-user"
                                               id="exampleInputPassword" placeholder="请输入密码">
                                    </div>

                                    <div class="form-group">
                                        <div class="custom-control custom-checkbox small">
                                            <input type="checkbox" class="custom-control-input" id="customCheck">
                                            <label class="custom-control-label" for="customCheck">记住我</label>
                                        </div>
                                    </div>

                                    <button href="index.html" class="btn btn-primary btn-user btn-block">
                                        登陆
                                    </button>

                                </form>
                                <hr>
                                <div class="text-center">
                                    <a class="small" href="/register">跳转到注册页面</a>&nbsp;&nbsp;
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

        </div>

    </div>

</div>


</body>

</html>
from flask import Flask, request, render_template, session, redirect, jsonify
from utils import query
from utils.getHomeData import *
from utils.getComments_cData import *
from utils.getActor_tData import *
from utils.getRate_tData import *
from utils.getHotness import *
from utils.getCommentData import *
from utils.getType_tData import *
from utils.getLikes import *
from utils.getHotness_duibi import *
from utils.getHotness_yuyue import *
import re

app = Flask(__name__)
app.secret_key = 'This is secret_key you know ?'


@app.route('/login', methods=['GET', 'POST'])
def login():
    if request.method == 'GET':
        return render_template('login.html')
    elif request.method == 'POST':
        request.form = dict(request.form)

    def filter_fn(item):
        return request.form['email'] in item

    users = query.querys('select * from user where email = %s', [request.form['email']], 'select')
    filter_list = list(filter(filter_fn, users))

    if len(filter_list):
        if request.form['password'] == filter_list[0][2]:
            session['email'] = request.form['email']
            return redirect('/home')
            # return render_template('error.html', message='登陆成功!')
        else:
            return render_template('error.html', message='密码错误!')
    else:
        return render_template('error.html', message='不存在该用户!')


@app.route('/loginout')
def loginout():
    session.clear()
    return redirect('/login')


@app.route('/register', methods=['GET', 'POST'])
def register():
    if request.method == 'GET':
        return render_template('register.html')
    elif request.method == 'POST':
        request.form = dict(request.form)
        if request.form['password'] != request.form['passwordChecked']:
            return render_template('error.html', message='两次密码不符合!')

    def filter_fn(item):
        return request.form['email'] in item

    users = query.querys('select * from user', [], 'select')
    filter_list = list(filter(filter_fn, users))

    if len(filter_list):
        return render_template('error.html', message='该用户已被注册!')
    else:
        query.querys('insert into user(email,password) values (%s,%s)',
                     [request.form['email'], request.form['password']])
        return redirect('/login')


@app.route('/home', methods=['GET', 'POST'])
def home():
    email = session.get('email')
    maxMovieLen, maxRate, maxCasts, maxHotness, maxTypes, maxComment = getHomeData()
    typeEcharData = getTypesEcharData()
    row, columns = getRateEcharData()

    return render_template(
        'index.html',
        email=email,
        maxMovieLen=maxMovieLen,
        maxRate=maxRate,
        maxCasts=maxCasts,
        maxHotness=maxHotness,
        maxTypes=maxTypes,
        maxComment=maxComment,
        typeEcharData=typeEcharData,
        row=row,
        columns=columns,
    )


# 预约热度
@app.route('/hotness_yuyue_t')
def hotness_yuyue_t():
    email = session.get('email')
    row, columns = getHotnessData_yuyueTop10()
    return render_template(
        'hotness_yuyue_t.html',
        email=email,
        row=row,
        columns=columns,
    )



# 热度top10
@app.route('/hotness_t')
def hotness_t():
    email = session.get('email')
    row, columns = getHotnessDataTop10()
    return render_template(
        'hotness_t.html',
        email=email,
        row=row,
        columns=columns,
    )


# 讨论数
@app.route('/comment_t')
def comment_t():
    email = session.get('email')
    rowCasts, columnsCasts = getCommentDataTop10()
    return render_template(
        'comment_t.html',
        email=email,
        rowCasts=rowCasts,
        columnsCasts=columnsCasts
    )


# 热度过万
@app.route('/likes_t')
def likes_t():
    email = session.get('email')
    rowCasts, columnsCasts = getLikesDataTop10()
    return render_template(
        'likes_t.html',
        email=email,
        rowCasts=rowCasts,
        columnsCasts=columnsCasts
    )


# 网剧和电视剧热度对比
@app.route('/hotness_duibi_t')
def hotness_duibi_t():
    email = session.get('email')
    wangju_data, dianshiju_data = getHotnessData_duibi()  # 假设这样返回数据
    row_wangju, columns_wangju = wangju_data
    row_dianshiju, columns_dianshiju = dianshiju_data

    # 将网剧和电视剧的数据都传递给模板
    return render_template(
        'hotness_duibi_t.html',
        email=email,
        wangju_titles=row_wangju,
        wangju_hotness=columns_wangju,
        dianshiju_titles=row_dianshiju,
        dianshiju_hotness=columns_dianshiju
    )


# 评分
@app.route('/rate_t/<type>', methods=['GET', 'POST'])
def rate_t(type):
    email = session.get('email')
    typeList = getAllTypes()
    row, columns = getAllRateDataByType(type)
    return render_template(
        'rate_t.html',
        email=email,
        typeList=typeList,
        type=type,
        row=row,
        columns=columns,
    )


# 三大类型
@app.route('/type_t')
def type_t():
    email = session.get('email')
    typesData_dianshiju = getTypeData_dianshiju()
    typesData_zoyi = getTypeData_zoyi()
    typesData_wangju = getTypeData_wangju()
    return render_template(
        'type_t.html',
        email=email,
        typesData_dianshiju=typesData_dianshiju,
        typesData_zoyi=typesData_zoyi,
        typesData_wangju=typesData_wangju,
    )


# 导演、演员
@app.route('/actor_t')
def actor_t():
    email = session.get('email')
    row, columns = getDirectorsDataTop20()
    rowCasts, columnsCasts = getCastsDataTop20()
    return render_template(
        'actor_t.html',
        email=email,
        row=row,
        columns=columns,
        rowCasts=rowCasts,
        columnsCasts=columnsCasts
    )


# 评论词云图
@app.route('/comments_c', methods=['GET', 'POST'])
def comments_c():
    email = session.get('email')
    if request.method == 'GET':
        return render_template('comments_c.html', email=email)
    else:
        resSrc, searchName = getCommentsImage(dict(request.form)['searchIpt'])
    return render_template('comments_c.html', email=email, resSrc=resSrc, searchName=searchName)


# 演员名词云图
@app.route('/casts_c', methods=['GET', 'POST'])
def casts_c():
    email = session.get('email')
    return render_template('casts_c.html', email=email)


@app.route('/')
def allRequest():
    return redirect('/login')


# 定义了一个 Flask 应用的全局前置请求处理器(before request handler)
# 它会在每次请求到达 Flask 应用之前运行
@app.before_request
def before_requre():
    # 定义一个正则表达式模式,匹配以 '/static' 开头的路径
    pat = re.compile(r'^/static')

    # 如果请求的路径匹配 '/static' 开头,则不进行后续的检查,直接返回
    # 这意味着静态文件的请求不会被后续的认证逻辑所拦截
    if re.search(pat, request.path):
        return

    # 如果请求的路径是 "/login",同样不进行后续的检查,直接返回
    # 这允许用户直接访问登录页面,而不需要先登录
    if request.path == "/login":
        return

    # 如果请求的路径是 '/register',同样不进行后续的检查,直接返回
    # 假设 '/register' 是注册页面的路径,允许用户直接访问注册页面
    if request.path == '/register':
        return

    # 尝试从 session 中获取用户的电子邮件地址
    email = session.get('email')

    # 如果 session 中存在电子邮件地址(即用户已登录)
    if email:
        # 则不进行任何操作,返回 None 表示继续处理该请求
        return None

    # 如果 session 中不存在电子邮件地址(即用户未登录)
    # 则重定向用户到登录页面 '/login'
    return redirect('/login')


if __name__ == '__main__':
    app.run()

源码下载

链接:https://pan.baidu.com/s/1V-ovZbb6Jhl6jWqFSoCBqg
提取码:1234


网站公告

今日签到

点亮在社区的每一天
去签到