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()
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
【资源说明】 基于Python+Flask的客户大数据分析系统源码+全部资料齐全.zip基于Python+Flask的客户大数据分析系统源码+全部资料齐全.zip 【备注】 1、该项目是个人高分项目源码,已获导师指导认可通过,答辩评审分达到95分 2、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 3、本项目适合计算机相关专业(人工智能、通信工程、自动化、电子信息、物联网等)的在校学生、老师或者企业员工下载使用,也可作为毕业设计、课程设计、作业、项目初期立项演示等,当然也适合小白学习进阶。 4、如果基础还行,可以在此代码基础上进行修改,以实现其他功能,也可直接用于毕设、课设、作业等。 欢迎下载,沟通交流,互相学习,共同进步!
资源推荐
资源详情
资源评论
收起资源包目录
基于Python+Flask的客户大数据分析系统源码+全部资料齐全.zip (518个子文件)
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
共 518 条
- 1
- 2
- 3
- 4
- 5
- 6
资源评论
不走小道
- 粉丝: 3210
- 资源: 5120
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功