博主介绍:✌全网粉丝10W+,前互联网大厂软件研发、集结硕博英豪成立工作室。专注于计算机相关专业毕业设计项目实战6年之久,选择我们就是选择放心、选择安心毕业✌感兴趣的可以先收藏起来,点赞、关注不迷路✌
毕业设计:2023-2024年计算机毕业设计1000套(建议收藏)
毕业设计:2023-2024年最新最全计算机专业毕业设计选题汇总
1、项目介绍
技术栈:
Python语言、Flask框架、requests爬虫、sqlite数据库、时间序列预测fbprophet库、预测出行速度、拥堵预测、HTML
2、项目界面
(1)北京大数据智慧交通数据分析大屏
(2)智慧交通数据
(3)广州大数据智慧交通数据分析大屏
(4)出行速度预测分析
(5)拥堵系数预测
(6)注册登录界面
(7)后台数据管理
3、项目说明
本课题通过网络爬虫技术采集高德地图提供的一个交通情报和路况报告网站,获取交通拥堵情况、路况状况数据,为系统的搭建提供了夯实的基础。使用Python语言对数据进行采集,使用pycharm内嵌的sqlite数据库对数据进行存储;采用时间序列预测算法,对各城市的出行速度进行预测。通过使用直观的可视化工具,如图表、地图等,系统可以将数据结果以更易理解的方式呈现给用户。同时,系统可能提供友好的用户界面,使用户能够方便地输入选项,并进行交互式的数据分析。本课题主要分为以下六个模块:
1、数据获取
使用Python网络爬虫技术结合requests爬虫框架采集高德地图提供的一个交通情报和路况报告网站,获取交通拥堵情况、路况状况数据。
2、注册登录
用户必须先进行注册,输入用户名、密码进行注册,系统根据账号密码查询数据库进行验证,重复注册系统会提示用户已存在。
3、北京交通数据分析可视化
系统对采集的北京交通数据进行分析与可视化展示,包括:各个行政区的最新拥堵系数、拥堵情况变化、拥堵系数变化、出行速度情况等等指标。
4、广州交通数据分析可视化
系统对采集的广州交通数据进行分析与可视化展示,包括:各个行政区的最新拥堵系数、拥堵情况变化、拥堵系数变化、出行速度情况等等指标。
5、出行速度预测
本文使用了时间序列预测算法,对各城市的出行速度进行预测。
6、后台数据管理
系统开发了数据后台管理,管理员可以登录账号进入后台数据管理界面,对采集的数据进行增删改查,对前台注册的用户进行管理和权限设置。
4、核心代码
# !/usr/bin/env python
# _*_ coding: utf-8 _*_
from flask import Flask, request, render_template,jsonify,abort,session,redirect, url_for
import os
import models
from models import app
import time
from sqlalchemy import or_,and_
import pandas
import datetime
from flask_sqlalchemy import SQLAlchemy
from flask_admin import Admin
from flask_admin.contrib.sqla import ModelView
app = Flask(__name__)
# 配置sqlite数据库
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///transportation.db'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.secret_key = 'a_secret_key'
db = SQLAlchemy(app)
# 初始化Flask Admin
admin = Admin(app, name='后台管理')
@app.route('/', methods=['GET', 'POST'])
@app.route('/index', methods=['GET', 'POST'])
def index():#主页
uuid = session.get('uuid')#获取session的数据,判断是否登录,如未登录跳转到登录页
if uuid:
if not models.User.query.get(uuid):
return redirect(url_for('login'))
else:
username = models.User.query.get(uuid).name
else:
return redirect(url_for('login'))
if request.method == 'GET':
results = models.Transportation.query.all()
return render_template('index.html',**locals())
@app.route('/yuce', methods=['GET', 'POST'])
def yuce():
if request.method == 'GET':
result = list(set([str(i.city) + '-' + str(i.city_proper) for i in models.Transportation.query.all()]))
result.sort()
name = request.args.get('name','广州-天河区')
print(name)
name = name.split('-')[-1]
datas = yuce1(name)
print(datas)
riqi = [i['riqi'] for i in datas]
piaofang = [round(i['xisu'],2) for i in datas]
return render_template('yuce.html',**locals())
@app.route('/yuce_prophet', methods=['GET', 'POST'])
def yuce_prophet():
if request.method == 'GET':
result = list(set([str(i.city) + '-' + str(i.city_proper) for i in models.Transportation.query.all()]))
result.sort()
name = request.args.get('name','广州-天河区')
print(name)
name = name.split('-')[-1]
datas = yuce2(name)
print(datas)
return render_template('yuce_prophet.html',**locals())
@app.route('/gz_charts', methods=['GET', 'POST'])
def gz_charts():#主页
uuid = session.get('uuid')#获取session的数据,判断是否登录,如未登录跳转到登录页
if uuid:
if not models.User.query.get(uuid):
return redirect(url_for('login'))
else:
username = models.User.query.get(uuid).name
else:
return redirect(url_for('login'))
if request.method == 'GET':
sql_command = 'select * from Transportation '
df = pandas.read_sql(sql_command, models.db.engine)
datas = df[df['城市'].map(lambda xx:xx == '广州')]
city_propers = list(set([i[2] for i in datas.values.tolist()]))
city_propers.sort()
map_data = []
for resu in city_propers:
reslut = datas[datas['城区'].map(lambda xx: xx == resu)].values.tolist()
map_data.append({"name": resu, "value": reslut[-1][4]})
print(map_data)
#最新拥堵系数
city_proper_name = []
city_proper_index = []
for resu in city_propers:
reslut = datas[datas['城区'].map(lambda xx: xx == resu)].values.tolist()
city_proper_name.append(resu)
city_proper_index.append(reslut[-1][3])
#天河区拥堵情况变化
tianhe_names = []
tianhe_count = []
reslut = datas[datas['城区'].map(lambda xx: xx == '天河区')]
date_set = list(set([resu[-1].split(':')[0] for resu in reslut.values.tolist()]))
date_set.sort()
for resu in date_set[-24:]:
resu1 = reslut[reslut['获取日期'].map(lambda xx: xx.split(':')[0] == resu)].values.tolist()
tianhe_names.append(resu)
tianhe_count.append(resu1[0][4])
#荔湾区拥堵系数变化
liwan_names = []
liwan_count = []
reslut = datas[datas['城区'].map(lambda xx: xx == '荔湾区')]
date_set = list(set([resu[-1].split(':')[0] for resu in reslut.values.tolist()]))
date_set.sort()
for resu in date_set[-24:]:
resu1 = reslut[reslut['获取日期'].map(lambda xx: xx.split(':')[0] == resu)].values.tolist()
liwan_names.append(resu)
liwan_count.append(resu1[0][3])
#越秀区拥堵情况变化
yuexiu_names = []
yuexiu_count = []
reslut = datas[datas['城区'].map(lambda xx: xx == '越秀区')]
date_set = list(set([resu[-1].split(':')[0] for resu in reslut.values.tolist()]))
date_set.sort()
for resu in date_set[-24:]:
resu1 = reslut[reslut['获取日期'].map(lambda xx: xx.split(':')[0] == resu)].values.tolist()
yuexiu_names.append(resu)
yuexiu_count.append(resu1[0][4])
return render_template('gz_daping.html',**locals())
@app.route('/cq_charts', methods=['GET', 'POST'])
def cq_charts():#主页
uuid = session.get('uuid')#获取session的数据,判断是否登录,如未登录跳转到登录页
if uuid:
if not models.User.query.get(uuid):
return redirect(url_for('login'))
else:
username = models.User.query.get(uuid).name
else:
return redirect(url_for('login'))
if request.method == 'GET':
sql_command = 'select * from Transportation '
df = pandas.read_sql(sql_command, models.db.engine)
datas = df[df['城市'].map(lambda xx:xx == '重庆')]
city_propers = list(set([i[2] for i in datas.values.tolist()]))
city_propers.sort()
map_data = []
for resu in city_propers:
reslut = datas[datas['城区'].map(lambda xx: xx == resu)].values.tolist()
map_data.append({"name": resu, "value": reslut[-1][4]})
print(map_data)
#最新拥堵系数
city_proper_name = []
city_proper_index = []
for resu in city_propers:
reslut = datas[datas['城区'].map(lambda xx: xx == resu)].values.tolist()
city_proper_name.append(resu)
city_proper_index.append(reslut[-1][3])
#大渡口区拥堵情况变化
tianhe_names = []
tianhe_count = []
reslut = datas[datas['城区'].map(lambda xx: xx == '大渡口区')]
date_set = list(set([resu[-1].split(':')[0] for resu in reslut.values.tolist()]))
date_set.sort()
for resu in date_set[-24:]:
resu1 = reslut[reslut['获取日期'].map(lambda xx: xx.split(':')[0] == resu)].values.tolist()
tianhe_names.append(resu)
tianhe_count.append(resu1[0][4])
#江北区拥堵系数变化
liwan_names = []
liwan_count = []
reslut = datas[datas['城区'].map(lambda xx: xx == '江北区')]
date_set = list(set([resu[-1].split(':')[0] for resu in reslut.values.tolist()]))
date_set.sort()
for resu in date_set[-24:]:
resu1 = reslut[reslut['获取日期'].map(lambda xx: xx.split(':')[0] == resu)].values.tolist()
liwan_names.append(resu)
liwan_count.append(resu1[0][3])
#南岸区拥堵情况变化
yuexiu_names = []
yuexiu_count = []
reslut = datas[datas['城区'].map(lambda xx: xx == '南岸区')]
date_set = list(set([resu[-1].split(':')[0] for resu in reslut.values.tolist()]))
date_set.sort()
for resu in date_set[-24:]:
resu1 = reslut[reslut['获取日期'].map(lambda xx: xx.split(':')[0] == resu)].values.tolist()
yuexiu_names.append(resu)
yuexiu_count.append(resu1[0][4])
return render_template('cq_daping.html',**locals())
@app.route('/wuhan_charts', methods=['GET', 'POST'])
def wuhan_charts():#主页
uuid = session.get('uuid')#获取session的数据,判断是否登录,如未登录跳转到登录页
if uuid:
if not models.User.query.get(uuid):
return redirect(url_for('login'))
else:
username = models.User.query.get(uuid).name
else:
return redirect(url_for('login'))
if request.method == 'GET':
sql_command = 'select * from Transportation '
df = pandas.read_sql(sql_command, models.db.engine)
datas = df[df['城市'].map(lambda xx:xx == '武汉')]
city_propers = list(set([i[2] for i in datas.values.tolist()]))
city_propers.sort()
map_data = []
for resu in city_propers:
reslut = datas[datas['城区'].map(lambda xx: xx == resu)].values.tolist()
map_data.append({"name": resu, "value": reslut[-1][4]})
print(map_data)
#最新拥堵系数
city_proper_name = []
city_proper_index = []
for resu in city_propers:
reslut = datas[datas['城区'].map(lambda xx: xx == resu)].values.tolist()
city_proper_name.append(resu)
city_proper_index.append(reslut[-1][3])
#江汉区拥堵情况变化
tianhe_names = []
tianhe_count = []
reslut = datas[datas['城区'].map(lambda xx: xx == '江汉区')]
date_set = list(set([resu[-1].split(':')[0] for resu in reslut.values.tolist()]))
date_set.sort()
for resu in date_set[-24:]:
resu1 = reslut[reslut['获取日期'].map(lambda xx: xx.split(':')[0] == resu)].values.tolist()
tianhe_names.append(resu)
tianhe_count.append(resu1[0][4])
#武昌区拥堵系数变化
liwan_names = []
liwan_count = []
reslut = datas[datas['城区'].map(lambda xx: xx == '武昌区')]
date_set = list(set([resu[-1].split(':')[0] for resu in reslut.values.tolist()]))
date_set.sort()
for resu in date_set[-24:]:
resu1 = reslut[reslut['获取日期'].map(lambda xx: xx.split(':')[0] == resu)].values.tolist()
liwan_names.append(resu)
liwan_count.append(resu1[0][3])
#江岸区拥堵情况变化
yuexiu_names = []
yuexiu_count = []
reslut = datas[datas['城区'].map(lambda xx: xx == '江岸区')]
date_set = list(set([resu[-1].split(':')[0] for resu in reslut.values.tolist()]))
date_set.sort()
for resu in date_set[-24:]:
resu1 = reslut[reslut['获取日期'].map(lambda xx: xx.split(':')[0] == resu)].values.tolist()
yuexiu_names.append(resu)
yuexiu_count.append(resu1[0][4])
return render_template('wuhan_daping.html',**locals())
@app.route('/zhangzhou_daping', methods=['GET', 'POST'])
def zhangzhou_daping():#主页
uuid = session.get('uuid')#获取session的数据,判断是否登录,如未登录跳转到登录页
if uuid:
if not models.User.query.get(uuid):
return redirect(url_for('login'))
else:
username = models.User.query.get(uuid).name
else:
return redirect(url_for('login'))
if request.method == 'GET':
sql_command = 'select * from Transportation '
df = pandas.read_sql(sql_command, models.db.engine)
datas = df[df['城市'].map(lambda xx:xx == '漳州')]
city_propers = list(set([i[2] for i in datas.values.tolist()]))
city_propers.sort()
map_data = []
for resu in city_propers:
reslut = datas[datas['城区'].map(lambda xx: xx == resu)].values.tolist()
map_data.append({"name": resu, "value": reslut[-1][4]})
print(map_data)
#最新拥堵系数
city_proper_name = []
city_proper_index = []
for resu in city_propers:
reslut = datas[datas['城区'].map(lambda xx: xx == resu)].values.tolist()
city_proper_name.append(resu)
city_proper_index.append(reslut[-1][3])
#龙文区拥堵情况变化
tianhe_names = []
tianhe_count = []
reslut = datas[datas['城区'].map(lambda xx: xx == '龙文区')]
date_set = list(set([resu[-1].split(':')[0] for resu in reslut.values.tolist()]))
date_set.sort()
for resu in date_set[-24:]:
resu1 = reslut[reslut['获取日期'].map(lambda xx: xx.split(':')[0] == resu)].values.tolist()
tianhe_names.append(resu)
tianhe_count.append(resu1[0][4])
#芗城区拥堵系数变化
liwan_names = []
liwan_count = []
reslut = datas[datas['城区'].map(lambda xx: xx == '芗城区')]
date_set = list(set([resu[-1].split(':')[0] for resu in reslut.values.tolist()]))
date_set.sort()
for resu in date_set[-24:]:
resu1 = reslut[reslut['获取日期'].map(lambda xx: xx.split(':')[0] == resu)].values.tolist()
liwan_names.append(resu)
liwan_count.append(resu1[0][3])
#龙文区拥堵情况变化
yuexiu_names = []
yuexiu_count = []
reslut = datas[datas['城区'].map(lambda xx: xx == '龙文区')]
date_set = list(set([resu[-1].split(':')[0] for resu in reslut.values.tolist()]))
date_set.sort()
for resu in date_set[-24:]:
resu1 = reslut[reslut['获取日期'].map(lambda xx: xx.split(':')[0] == resu)].values.tolist()
yuexiu_names.append(resu)
yuexiu_count.append(resu1[0][4])
return render_template('zhangzhou_daping.html',**locals())
@app.route('/ganzhou_charts', methods=['GET', 'POST'])
def ganzhou_charts():#主页
uuid = session.get('uuid')#获取session的数据,判断是否登录,如未登录跳转到登录页
if uuid:
if not models.User.query.get(uuid):
return redirect(url_for('login'))
else:
username = models.User.query.get(uuid).name
else:
return redirect(url_for('login'))
if request.method == 'GET':
sql_command = 'select * from Transportation '
df = pandas.read_sql(sql_command, models.db.engine)
datas = df[df['城市'].map(lambda xx:xx == '赣州')]
city_propers = list(set([i[2] for i in datas.values.tolist()]))
city_propers.sort()
map_data = []
for resu in city_propers:
reslut = datas[datas['城区'].map(lambda xx: xx == resu)].values.tolist()
map_data.append({"name": resu, "value": reslut[-1][4]})
print(map_data)
#最新拥堵系数
city_proper_name = []
city_proper_index = []
for resu in city_propers:
reslut = datas[datas['城区'].map(lambda xx: xx == resu)].values.tolist()
city_proper_name.append(resu)
city_proper_index.append(reslut[-1][3])
#章贡区拥堵情况变化
tianhe_names = []
tianhe_count = []
reslut = datas[datas['城区'].map(lambda xx: xx == '章贡区')]
date_set = list(set([resu[-1].split(':')[0] for resu in reslut.values.tolist()]))
date_set.sort()
for resu in date_set[-24:]:
resu1 = reslut[reslut['获取日期'].map(lambda xx: xx.split(':')[0] == resu)].values.tolist()
tianhe_names.append(resu)
tianhe_count.append(resu1[0][4])
#南康区拥堵系数变化
liwan_names = []
liwan_count = []
reslut = datas[datas['城区'].map(lambda xx: xx == '南康区')]
date_set = list(set([resu[-1].split(':')[0] for resu in reslut.values.tolist()]))
date_set.sort()
for resu in date_set[-24:]:
resu1 = reslut[reslut['获取日期'].map(lambda xx: xx.split(':')[0] == resu)].values.tolist()
liwan_names.append(resu)
liwan_count.append(resu1[0][3])
#赣县区拥堵情况变化
yuexiu_names = []
yuexiu_count = []
reslut = datas[datas['城区'].map(lambda xx: xx == '赣县区')]
date_set = list(set([resu[-1].split(':')[0] for resu in reslut.values.tolist()]))
date_set.sort()
for resu in date_set[-24:]:
resu1 = reslut[reslut['获取日期'].map(lambda xx: xx.split(':')[0] == resu)].values.tolist()
yuexiu_names.append(resu)
yuexiu_count.append(resu1[0][4])
return render_template('ganzhou_daping.html',**locals())
@app.route('/bj_charts', methods=['GET', 'POST'])
def bj_charts():#主页
uuid = session.get('uuid')#获取session的数据,判断是否登录,如未登录跳转到登录页
if uuid:
if not models.User.query.get(uuid):
return redirect(url_for('login'))
else:
username = models.User.query.get(uuid).name
else:
return redirect(url_for('login'))
if request.method == 'GET':
sql_command = 'select * from Transportation '
df = pandas.read_sql(sql_command, models.db.engine)
datas = df[df['城市'].map(lambda xx:xx == '北京')]
city_propers = list(set([i[2] for i in datas.values.tolist()]))
city_propers.sort()
map_data = []
for resu in city_propers:
reslut = datas[datas['城区'].map(lambda xx: xx == resu)].values.tolist()
map_data.append({"name": resu, "value": reslut[-1][4]})
print(map_data)
#最新拥堵系数
city_proper_name = []
city_proper_index = []
for resu in city_propers:
reslut = datas[datas['城区'].map(lambda xx: xx == resu)].values.tolist()
city_proper_name.append(resu)
city_proper_index.append(reslut[-1][3])
#朝阳区拥堵情况变化
tianhe_names = []
tianhe_count = []
reslut = datas[datas['城区'].map(lambda xx: xx == '朝阳区')]
date_set = list(set([resu[-1].split(':')[0] for resu in reslut.values.tolist()]))
date_set.sort()
for resu in date_set[-24:]:
resu1 = reslut[reslut['获取日期'].map(lambda xx: xx.split(':')[0] == resu)].values.tolist()
tianhe_names.append(resu)
tianhe_count.append(resu1[0][4])
#海淀区拥堵系数变化
liwan_names = []
liwan_count = []
reslut = datas[datas['城区'].map(lambda xx: xx == '海淀区')]
date_set = list(set([resu[-1].split(':')[0] for resu in reslut.values.tolist()]))
date_set.sort()
for resu in date_set[-24:]:
resu1 = reslut[reslut['获取日期'].map(lambda xx: xx.split(':')[0] == resu)].values.tolist()
liwan_names.append(resu)
liwan_count.append(resu1[0][3])
#西城区拥堵情况变化
yuexiu_names = []
yuexiu_count = []
reslut = datas[datas['城区'].map(lambda xx: xx == '西城区')]
date_set = list(set([resu[-1].split(':')[0] for resu in reslut.values.tolist()]))
date_set.sort()
for resu in date_set[-24:]:
resu1 = reslut[reslut['获取日期'].map(lambda xx: xx.split(':')[0] == resu)].values.tolist()
yuexiu_names.append(resu)
yuexiu_count.append(resu1[0][4])
return render_template('bj_daping.html',**locals())
from collections import OrderedDict
import pandas as pd
import models
from sqlalchemy import or_,and_
import datetime
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
import numpy
import traceback
def yuce1(name):
try:
sql_command = 'select * from Transportation '
df = pandas.read_sql(sql_command, models.db.engine)
da = df[df['城区'].map(lambda xx: xx == name)]
datas = df[df['城区'].map(lambda xx: xx == name)].values.tolist()
date_day = list(set([int(datetime.datetime.strptime(i[-1].split(':')[0],'%Y-%m-%d %H').strftime('%Y%m%d%H')) for i in datas]))
date_day.sort()
print(date_day)
liuliang = []
for i in date_day:
record_list = da[da['获取日期'].map(
lambda xx:int(datetime.datetime.strptime(xx.split(':')[0],'%Y-%m-%d %H').strftime('%Y%m%d%H')) == i )].values.tolist()
liuliang.append(record_list[-1][3])
# 数据集
examDict = {
'时间': date_day,
'系数': liuliang
}
print(examDict)
examOrderedDict = OrderedDict(examDict)
examDf = pd.DataFrame(examOrderedDict)
examDf.head()
# exam_x 即为feature
exam_x = examDf.loc[:, '时间']
# exam_y 即为label
exam_y = examDf.loc[:, '系数']
x_train, x_test, y_train, y_test = train_test_split(exam_x, exam_y, train_size=0.5)
x_train = x_train.values.reshape(-1, 1)
x_test = x_test.values.reshape(-1, 1)
model = LinearRegression()
model.fit(x_train, y_train)
LinearRegression(copy_X=True, fit_intercept=True, n_jobs=1)
# LinearRegression(copy_X=True, fit_intercept=True, n_jobs=1, normalize=False) 原始代码
rDf = examDf.corr()
model.score(x_test, y_test)
data1 = datetime.datetime.strptime(str(date_day[-5]), '%Y%m%d%H')
li1 = []
for i in range(24):
data1 = data1 + datetime.timedelta(hours=1)
li1.append([int(data1.strftime('%Y%m%d%H'))])
li2 = numpy.array(li1)
y_train_pred = model.predict(li2)
li2 = []
for i in range(len(li1)):
dicts = {}
dicts['riqi'] = li1[i][0]
dicts['xisu'] = round(abs(y_train_pred[i]),3)
li2.append(dicts)
return li2[2:]
except:
print(traceback.format_exc())
return []
from prophet import Prophet
# from fbprophet import Prophet
import pandas as pd
def yuce2(name):
sql_command = 'select * from Transportation'
df = pd.read_sql(sql_command, models.db.engine)
datas = df[df['城区'].map(lambda xx: xx == name)].values.tolist()
dicts = {
'ds': [],
'y': [],
'cap': [],
'floor': []
}
for resu in datas:
dicts['ds'].append(str(resu[-1].split(':')[0]))
dicts['y'].append(int(resu[4])),
dicts['cap'].append(60)
dicts['floor'].append(0)
df = pd.DataFrame.from_dict(dicts)
print(df)
# 拟合模型
m = Prophet(growth='logistic')
m.fit(df)
# 构建待预测日期数据框,periods = 365 代表除历史数据的日期外再往后推 365 天
future = m.make_future_dataframe(periods=15, freq='H')
future['cap'] = 60
future['floor'] = 0
# 预测数据集
forecast = m.predict(future)
data = forecast[['ds', 'yhat', 'yhat_lower', 'yhat_upper']]
dicts = data.to_dict(orient="list")
datas = []
for i in range(len(dicts['ds'])):
dicts1 = {}
dicts1['yhat'] = round(dicts['yhat'][i], 1)
dicts1['yhat_lower'] = dicts['yhat_lower'][i]
dicts1['yhat_upper'] = dicts['yhat_upper'][i]
dicts1['ds'] = dicts['ds'][i].strftime("%Y-%m-%d")
datas.append(dicts1)
datas = datas[-15:][::-1]
return datas
@app.route('/login', methods=['GET', 'POST'])
def login():
uuid = session.get('uuid')#如果已经登录则跳转到主页
datas = models.User.query.get(uuid)
if datas:
return redirect(url_for('index'))
if request.method=='GET':
return render_template('account/index.html')
elif request.method=='POST':
user = request.form.get('user')
password = request.form.get('password')
data = models.User.query.filter(and_(models.User.name==user,models.User.pwd==password)).all()
if not data:
return render_template('account/index.html',error='账号密码错误')
else:
session['uuid'] = data[0].id #账号密码正确,就把用户id记录到session里面
session.permanent = True
return redirect(url_for('index'))
@app.route('/loginout', methods=['GET'])
def loginout():
if request.method == 'GET':
session['uuid'] = ''#退出登录清楚记录
session.permanent = False
return redirect(url_for('login'))
@app.route('/signup', methods=['GET', 'POST'])
def signup():
if request.method == 'GET':
uuid = session.get('uuid')
datas = models.User.query.get(uuid)
if datas:
return redirect(url_for('index'))
return render_template('account/register.html')
elif request.method == 'POST':
user = request.form.get('user')
email = request.form.get('email')
password = request.form.get('password')
if models.User.query.filter(models.User.name == user).all():
return render_template('account/register.html', error='账号名已被注册')
elif user == '' or password == '' or email == '':
return render_template('account/register.html', error='输入不能为空')
else:
models.db.session.add(models.User(name=user, pwd=password,email=email))#注册用户信息
models.db.session.commit()
return redirect(url_for('login'))
if __name__ == '__main__':
app.run(debug=True)
🍅✌感兴趣的可以先收藏起来,点赞关注不迷路,想学习更多项目可以查看主页,大家在毕设选题,项目代码以及论文编写等相关问题都可以给我留言咨询,希望可以帮助同学们顺利毕业!🍅✌
5、源码获取方式
🍅由于篇幅限制,获取完整文章或源码、代做项目的,拉到文章底部即可看到个人联系方式。🍅文章来源:https://www.toymoban.com/news/detail-836334.html
点赞、收藏、关注,不迷路,下方查看👇🏻获取联系方式👇🏻文章来源地址https://www.toymoban.com/news/detail-836334.html
到了这里,关于大数据毕业设计:智慧交通数据分析系统 python 时间序列预测算法 爬虫 出行速度预测 拥堵预测(源码)✅的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!