import json
import random
from datetime import datetime
import user_portrait
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import base64
from io import BytesIO
import matplotlib
import warnings
import re
from wordcloud import WordCloud
import seaborn as sns
from sklearn.cluster import KMeans
from sklearn.metrics import silhouette_score
from sklearn.preprocessing import StandardScaler, MinMaxScaler
# %matplotlib inline
plt.rcParams['font.sans-serif'] = 'SimHei'
plt.rcParams['axes.unicode_minus'] = False
matplotlib.rcParams.update({'font.size' : 16})
plt.style.use('ggplot')
warnings.filterwarnings('ignore')
from flask import Flask, render_template, request, flash, redirect, session, jsonify
import pymysql
from sqlalchemy import null
app = Flask(__name__)
app.secret_key = "123"
def conn_db():
######## 数据库操作
# 1.链接数据库
conn = pymysql.connect(
host="127.0.0.1", port=3306,
db="customer_analysis", user="root", password="yyqxwhc.",
charset="utf8"
)
return conn
@app.route('/')
def home(): # put application's code here
return redirect("/page/template/login/login.html")
# **************** 登录 ****************
@app.route('/page/template/login/login.html')
def login(): # put application's code here
return render_template("page/template/login/login.html")
@app.route('/doLogin', methods=['GET', 'POST'])
def doLogin():
# 获取姓名 request.get('key')
name = request.form.get("username")
pwd = request.form.get("password")
print("username:", name, "password:", pwd)
# 1.连接数据库
conn = conn_db()
# 2.创建游标对象
cursor = conn.cursor()
# 3.sql语句
sql = "select * from user where username=%s and password=%s"
row = cursor.execute(sql, [name, pwd])
# 4.提交
conn.commit()
# 5.关闭
conn.close()
if row > 0:
session['username'] = name
return redirect("/index")
else:
flash("密码不正确")
return redirect("/page/template/login/login.html")
# **************** 注册 ****************
@app.route('/page/template/login/reg.html')
def reg():
return render_template("page/template/login/reg.html")
@app.route('/doReg', methods=['GET', 'POST'])
def doReg():
# 获取姓名 request.get('key')
name = request.form.get("username")
pwd = request.form.get("password")
email = request.form.get("email")
######## 数据库操作
# 1.链接数据库
conn = conn_db()
# 2.创建游标对象
cursor = conn.cursor()
# 3.sql语句
sql = "insert into user values(null, %s, %s, %s)"
row = cursor.execute(sql, [name, pwd, email])
# 4.提交
conn.commit()
# 5.关闭
conn.close()
if row > 0:
return redirect("/page/template/login/login.html")
else:
flash("注册失败")
return redirect("/page/template/login/reg.html")
# **************** 忘记密码 ****************
@app.route('/page/template/login/forget.html')
def forget(): # put application's code here
return render_template("page/template/login/forget.html")
@app.route('/doForget', methods=['GET', 'POST'])
def doForget():
# 获取姓名 request.get('key')
email = request.form.get("email")
pwd = request.form.get("password")
# 2.创建游标对象
conn = conn_db()
cursor = conn.cursor()
# 3.sql语句
sql = "update user set password=%s where email=%s "
row = cursor.execute(sql, [pwd, email])
# 4.提交
conn.commit()
# 5.关闭
conn.close()
if row > 0:
return redirect("/page/template/login/login.html")
else:
flash("更改失败")
return redirect("/page/template/login/forget.html")
# **************** 首页 ****************
@app.route('/index')
def index():
return render_template('index.html')
# **************** 首页-顶部栏 ****************
@app.route('/page/tpl/tpl-message.html')
def tpl_message():
return render_template('page/tpl/tpl-message.html')
@app.route('/page/tpl/tpl-lock-screen.html')
def tpl_lock_screen():
return render_template('page/tpl/tpl-lock-screen.html')
@app.route('/page/tpl/tpl-note.html')
def tpl_note():
return render_template('page/tpl/tpl-note.html')
@app.route('/page/tpl/tpl-password.html')
def tpl_password():
return render_template('page/tpl/tpl-password.html')
# 修改密码
@app.route('/page/tpl/tpl-password/change', methods=['GET', 'POST'])
def tpl_password_change():
username = session.get('username')
oldPsw = request.form.get('oldPsw')
newPsw = request.form.get('newPsw')
# 2.创建游标对象
conn = conn_db()
cursor = conn.cursor()
# 3.sql语句
sql = "update user set password=%s where username=%s and password=%s"
row = cursor.execute(sql, [newPsw, username, oldPsw])
# 4.提交
conn.commit()
# 5.关闭
conn.close()
if row == 0:
flash("更改失败")
return redirect("/index")
@app.route('/page/tpl/tpl-theme.html')
def tpl_theme():
return render_template('page/tpl/tpl-theme.html')
# **************** 首页-侧边栏-DashBoard ****************
# 工作台
@app.route("/page/console/workplace.html")
def workPlace():
return render_template("page/console/workplace.html")
# 控制台
@app.route("/page/console/console.html")
def console():
return render_template("page/console/console.html")
# 分析页
@app.route("/page/console/dashboard.html")
def dashBoard():
return render_template("page/console/dashboard.html")
# ****************首页-侧边栏-客户管理 ****************
# 客户管理
@app.route("/page/customer/customer.html")
def customerIndex():
return render_template("page/customer/customer.html")
def getCustomerJson(result): # 数据库中的role数据转为json格式用于前端Table输出
customer_vip = {}
customer_vip['code'] = 0
customer_vip['msg'] = ''
data = []
count = 0
for r in result:
count = count + 1
dict = {}
dict["memberId"] = r[0]
dict["bitrhday"] = r[1]
dict["sex"] = r[2]
dict["registerTime"] = r[3]
data.append(dict)
customer_vip['count'] = count
customer_vip['data'] = data
# print(user)
return jsonify(customer_vip)
@app.route("/page/customer/customer/jsonData", methods=['GET', 'POST'])
def customerJsonData(): # 展示以及查找数据库中的user数据
memberId = request.args.get("memberId")
sex = request.args.get("sex")
bitrhday = request.args.get("bitrhday")
# 2.创建游标对象
conn = conn_db()
cursor = conn.cursor()
if memberId:
if sex:
if bitrhday:
sql = "select * from vip_info1 where memberId=%s and sex=%s and bitrhday=%s "
row = cursor.execute(sql, [memberId, sex, bitrhday])
else:
sql = "select * from vip_info1 where memberId=%s and sex=%s "
row = cursor.execute(sql, [memberId, sex])
else:
if bitrhday:
sql = "select * from vip_info1 where memberId=%s and bitrhday=%s "
row = cursor.execute(sql, [memberId, bitrhday])
else:
sql = "select * from vip_info1 where memberId=%s "
row = cursor.execute(sql, [memberId])
else:
if sex:
if bitrhday:
sql = "select * from vip_info1 where sex=%s and bitrhday=%s "
row = cursor.execute(sql, [sex, bitrhday])
else:
sql = "select * from vip_info1 where sex=%s "
row = cursor.execute(sql, [sex])
else:
if bitrhday:
sql = "select * from vip_info1 where bitrhday=%s "
row = cursor.execute(sql, [bitrhday])
else:
sql = "select * from vip_info1 "
row = cursor.execute(sql)
result = cursor.fetchall()
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
CSDN IT狂飙上传的代码均可运行,功能ok的情况下才上传的,直接替换数据即可使用,小白也能轻松上手 【资源说明】 Python优秀项目 基于Flask+MySQL实现的客户大数据分析系统源码+全部资料齐全+部署文档.zip 1、代码压缩包内容 代码的项目文件 部署文档文件 2、代码运行版本 python3.7或者3.7以上的版本;若运行有误,根据提示GPT修改;若不会,私信博主(问题描述要详细) 3、运行操作步骤 步骤一:将代码的项目目录使用IDEA打开(IDEA要配置好python环境) 步骤二:根据部署文档或运行提示安装项目所需的库 步骤三:IDEA点击运行,等待程序服务启动完成 4、python资讯 如需要其他python项目的定制服务,可后台私信博主(注明你的项目需求) 4.1 python或人工智能项目辅导 4.2 python或人工智能程序定制 4.3 python科研合作 Django、Flask、Pytorch、Scrapy、PyQt、爬虫、可视化、大数据、推荐系统、人工智能、大模型
资源推荐
资源详情
资源评论
收起资源包目录
Python优秀项目 基于Flask+MySQL实现的客户大数据分析系统源码+全部资料齐全+部署文档.zip (520个子文件)
admin.css 96KB
layui.css 73KB
notice.css 59KB
skin.min.css 54KB
skin.min.css 54KB
main.css 27KB
skin.mobile.min.css 21KB
skin.mobile.min.css 21KB
content.min.css 17KB
content.inline.min.css 17KB
content.inline.min.css 17KB
content.min.css 17KB
layer.css 14KB
main.min.css 14KB
introJs.css 12KB
dropdown.css 11KB
layui.mobile.css 10KB
laydate.css 7KB
main.css 7KB
steps.css 7KB
metroStyle.css 6KB
zTreeStyle.css 6KB
test-1920.css 6KB
test-1280.css 6KB
test-1024.css 6KB
Cropper.css 5KB
cascader.css 5KB
main.min.css 3KB
city-picker.css 3KB
iconfont.css 2KB
tagsInput.css 2KB
main.css 2KB
main.css 2KB
Split.css 2KB
main.min.css 1KB
content.min.css 1KB
code.css 1KB
content.min.css 1KB
main.min.css 1004B
content.min.css 978B
content.min.css 957B
content.mobile.min.css 544B
content.mobile.min.css 544B
df1.csv 78.86MB
vip_info.csv 51.32MB
vip_info1.csv 9.4MB
consumers_profile.csv 6.14MB
LRFMPSX.csv 2.63MB
L.csv 2.1MB
iconfont.eot 46KB
ic_loading.gif 14KB
59.gif 10KB
22.gif 10KB
24.gif 8KB
13.gif 7KB
16.gif 7KB
39.gif 6KB
64.gif 6KB
63.gif 6KB
50.gif 6KB
loading-0.gif 6KB
4.gif 6KB
zTreeStandard.gif 5KB
1.gif 5KB
42.gif 5KB
71.gif 5KB
21.gif 5KB
20.gif 5KB
29.gif 5KB
metro.gif 5KB
70.gif 4KB
5.gif 4KB
17.gif 4KB
27.gif 4KB
9.gif 4KB
44.gif 4KB
11.gif 4KB
8.gif 4KB
3.gif 4KB
23.gif 4KB
34.gif 4KB
41.gif 4KB
38.gif 4KB
65.gif 3KB
32.gif 3KB
45.gif 3KB
7.gif 3KB
12.gif 3KB
26.gif 3KB
60.gif 3KB
2.gif 3KB
40.gif 3KB
25.gif 3KB
19.gif 3KB
66.gif 3KB
18.gif 3KB
46.gif 3KB
10.gif 3KB
28.gif 3KB
51.gif 3KB
共 520 条
- 1
- 2
- 3
- 4
- 5
- 6
资源评论
IT狂飙
- 粉丝: 4830
- 资源: 2652
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功