lin 6 months ago
parent 12a0f2af77
commit 587d58f8ea

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Black">
<option name="sdkName" value="Python 3.11 (pythonProject)" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (pythonProject)" project-jdk-type="Python SDK" />
</project>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/pythonProject.iml" filepath="$PROJECT_DIR$/.idea/pythonProject.iml" />
</modules>
</component>
</project>

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/pythonProject/.venv" />
<excludeFolder url="file://$MODULE_DIR$/用户登录/.venv" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Black">
<option name="sdkName" value="Python 3.11 (pythonProject)" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (pythonProject)" project-jdk-type="Python SDK" />
</project>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/pythonProject.iml" filepath="$PROJECT_DIR$/.idea/pythonProject.iml" />
</modules>
</component>
</project>

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.venv" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

Binary file not shown.

@ -0,0 +1,8 @@
# 默认忽略的文件
/shelf/
/workspace.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Black">
<option name="sdkName" value="Python 3.11 (用户登录)" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (用户登录)" project-jdk-type="Python SDK" />
</project>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/用户登录.iml" filepath="$PROJECT_DIR$/.idea/用户登录.iml" />
</modules>
</component>
</project>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

@ -0,0 +1,44 @@
from tkinter import *
user_login={'aaa':'123456','bbb':'888888','ccc':'333333'}
#定义登录次数
count=0
def login():
global count
username =entry_username.get()
if username not in user_login:
label_message.config(text='账号错误!')
else:
password =entry_password.get ()
if (password==user_login [username]):
label_message.config(text ='登录成功!')
else:
label_message.config(text='密码错误!还可以尝试{}'.format(2-count))
count =count +1
if count ==3:
label_message.config(text ='登录失败!')
btn_login.config(state="disabled")
#创建主窗口
window =Tk()
window.title("用户登录")
window.geometry("300x200")
#创建标签和输入框
label_username =Label(window,text="账号:")
label_username.pack()
entry_username =Entry(window)
entry_username.pack()
label_password=Label(window,text="密码:")
label_password.pack()
entry_password =Entry(window, show ='*')
entry_password.pack()
#创建登录按钮和消息提示标签
btn_login=Button(window, text="登录",command=login)
btn_login.pack()
label_message =Label (window, text ="")
label_message.pack()
#运行主循环
window.mainloop()

@ -0,0 +1,8 @@
# 默认忽略的文件
/shelf/
/workspace.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

@ -0,0 +1,15 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="HtmlUnknownAttribute" enabled="true" level="WARNING" enabled_by_default="true">
<option name="myValues">
<value>
<list size="1">
<item index="0" class="java.lang.String" itemvalue="width" />
</list>
</value>
</option>
<option name="myCustomValuesEnabled" value="true" />
</inspection_tool>
</profile>
</component>

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Black">
<option name="sdkName" value="Python 3.11" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11" project-jdk-type="Python SDK" />
</project>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/豆瓣.iml" filepath="$PROJECT_DIR$/.idea/豆瓣.iml" />
</modules>
</component>
</project>

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="Python 3.11" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TemplatesService">
<option name="TEMPLATE_CONFIGURATION" value="Jinja2" />
<option name="TEMPLATE_FOLDERS">
<list>
<option value="$MODULE_DIR$/python豆瓣电影数据可视化分析/项目/templates" />
</list>
</option>
</component>
</module>

@ -0,0 +1,10 @@
# 默认忽略的文件
/shelf/
/workspace.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# Zeppelin 忽略的文件
/ZeppelinRemoteNotebooks/

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Black">
<option name="sdkName" value="Python 3.11" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11" project-jdk-type="Python SDK" />
</project>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/python豆瓣电影数据可视化分析.iml" filepath="$PROJECT_DIR$/.idea/python豆瓣电影数据可视化分析.iml" />
</modules>
</component>
</project>

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="Python 3.11" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="PyDocumentationSettings">
<option name="format" value="PLAIN" />
<option name="myDocStringFormat" value="Plain" />
</component>
<component name="TemplatesService">
<option name="TEMPLATE_CONFIGURATION" value="Jinja2" />
<option name="TEMPLATE_FOLDERS">
<list>
<option value="$MODULE_DIR$/项目/templates" />
</list>
</option>
</component>
<component name="TestRunnerService">
<option name="PROJECT_TEST_RUNNER" value="py.test" />
</component>
</module>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="SqlDialectMappings">
<file url="file://$PROJECT_DIR$/项目/app.py" dialect="MySQL" />
</component>
</project>

@ -0,0 +1,4 @@
FLASK_APP = "app.py"
FLASK_ENV = "development"
FLASK_RUN_HOST = '0.0.0.0'
FLASK_RUN_PORT = '5000'

@ -0,0 +1,10 @@
# 默认忽略的文件
/shelf/
/workspace.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# Zeppelin 忽略的文件
/ZeppelinRemoteNotebooks/

@ -0,0 +1,7 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="PROJECT_PROFILE" value="Default" />
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Black">
<option name="sdkName" value="Python 3.11 (项目) (2)" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (测试打包环境)" project-jdk-type="Python SDK" />
</project>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/项目.iml" filepath="$PROJECT_DIR$/.idea/项目.iml" />
</modules>
</component>
</project>

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="Flask">
<option name="enabled" value="true" />
</component>
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="jdk" jdkName="Python 3.11 (测试打包环境)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TemplatesService">
<option name="TEMPLATE_CONFIGURATION" value="Jinja2" />
<option name="TEMPLATE_FOLDERS">
<list>
<option value="$MODULE_DIR$/../项目\templates" />
</list>
</option>
</component>
</module>

@ -0,0 +1,337 @@
from flask import Flask, request, render_template, session, redirect, jsonify
from utils import query
from utils.getHomeData import *
from utils.getSearchData import *
from utils.getTime_tData import *
from utils.getRate_tData import *
from utils.getMapData import *
from utils.getType_tData import *
from utils.getActor_tData import *
from utils.getTableData import *
from utils.getComments_cData import *
import re
app = Flask(__name__)
app.secret_key = 'This is secret_key you know ?'
@app.route('/login', methods=['GET', 'POST'])
def login():
error_message = None
if request.method == 'GET':
return render_template('login.html')
elif request.method == 'POST':
session.clear()
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')
else:
error_message = '密码错误!'
else:
error_message = '不存在该用户!'
return render_template('login.html', error_message=error_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('register.html', error_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('register.html', error_message='该用户已被注册!')
else:
query.querys('insert into user(email,password) values (%s,%s)',
[request.form['email'], request.form['password']])
return redirect('/login')
# @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')
# tableData = getTableData()
# tableData = getTableDataByTablePage()
@app.route('/home', methods=['GET', 'POST'])
def home():
email = session.get('email')
maxMovieLen, maxRate, maxCasts, maxCountry, maxTypes, maxLang = getHomeData()
typeEcharData = getTypesEcharData()
row, columns = getRateEcharData()
tableData = getTableData()
return render_template(
'index.html',
email=email,
maxMovieLen=maxMovieLen,
maxRate=maxRate,
maxCasts=maxCasts,
maxCountry=maxCountry,
maxTypes=maxTypes,
maxLang=maxLang,
typeEcharData=typeEcharData,
row=row,
columns=columns,
tableData=tableData,
)
# 电影预告片
@app.route('/movie/<movieName>')
def movie(movieName):
movieUrl = getMovieUrlById(movieName)
return render_template('movie.html', movieUrl=movieUrl)
# @app.route('/movie/<int:movieid>')
# def movie(movieid):
# movieUrl = getMovieUrlById(movieid)
# print(movieUrl)
# return render_template('movie.html', movieUrl=movieUrl)
# 搜索
@app.route('/search/<int:movieId>', methods=['GET', 'POST'])
def search(movieId):
email = session.get('email')
if request.method == 'GET':
resultData = getMovieDetailById(movieId)
else:
request.form = dict(request.form)
resultData = getMovieDetailBySearchWord(request.form['searchWord'])
# print(resultData)
return render_template('search.html', email=email, resultData=resultData)
# 时间
@app.route('/time_t')
def time_t():
row, columns = getYearData()
moveTimeDate = getMovieTimeData()
email = session.get('email')
return render_template('time_t.html', email=email, row=row, columns=columns, moveTimeDate=moveTimeDate)
# 评分
@app.route('/rate_t/<type>', methods=['GET', 'POST'])
def rate_t(type):
email = session.get('email')
typeList = getAllTypes()
# print(typeList)
# print(type)
row, columns = getAllRateDataByType(type)
# print(row, columns)
yearMenRow, yearMenColumns = getYearMeanData()
if request.method == 'GET':
startData, searchName = getStart('')
else:
request.form = dict(request.form)
startData, searchName = getStart(request.form['searchIpt'])
print(startData, searchName)
return render_template(
'rate_t.html',
email=email,
typeList=typeList,
type=type,
row=row,
columns=columns,
startData=startData,
searchName=searchName,
yearMenRow=yearMenRow,
yearMenColumns=yearMenColumns
)
# 地图
@app.route('/map_t')
def map_t():
email = session.get('email')
row, columns = getMapData()
# print(row, type(row))
# print(columns, type(columns))
langRow, langColumns = getLangData()
return render_template('map_t.html', email=email, row=row, columns=columns, langRow=langRow,
langColumns=langColumns)
# 类型
@app.route('/type_t')
def type_t():
email = session.get('email')
typesData = getTypeData()
return render_template('type_t.html', email=email, typesData=typesData)
# 导演、演员
@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('/table/<movieName>')
def table(movieName):
email = session.get('email')
tableData = delMovieByMoiveName(movieName)
# return redirect('/table/0')
# tableData = getTableDataByTablePage()
return render_template('table.html', email=email, tableData=tableData)
# 评论词云图
@app.route('/comments_c', methods=['GET', 'POST'])
def comments_c():
email = session.get('email')
resSrc, searchName = '', '' # 初始化为空字符串
if request.method == 'POST':
searchIpt = request.form['searchIpt']
resSrc, searchName = getCommentsImage(searchIpt)
# 如果没有找到匹配项resSrc 应该是空字符串,此时不渲染图片
return render_template('comments_c.html', email=email, resSrc=resSrc, searchName=searchName)
# 标题词云图
@app.route('/title_c', methods=['GET', 'POST'])
def title_c():
email = session.get('email')
return render_template('title_c.html', email=email)
# 简介词云图
@app.route('/summary_c', methods=['GET', 'POST'])
def summary_c():
email = session.get('email')
return render_template('summary_c.html', email=email)
# 演员名词云图
@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()

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save