目录 一、前言 二、实验代码 1、 app.py 2、__init__.py 3、logicOperation.py 4、font-awesome.min.css 5、swiper-bundle.min.css 和 swiper-bundl
目录
5、swiper-bundle.min.css 和 swiper-bundle.min.js
实验四有6个题可以选(如下图所示),吕同学懒得全看了,反正题目难度听老师说都差不多,我就直接做第一题了。
主要是要做前三个问题,第一问“Building the database"本博客不涉及,第二问“MySQL Implementation”本博客也不涉及,主要放上第三问的代码并进行简单的说明。
上图为翻译版实验要求。
上图为代码结构。
from flask import Flaskfrom blueprint import lpbpapp = Flask(__name__)app.reGISter_blueprint(lpbp)if __name__ == '__main__': app.run()
from .logicOperation import bp as lpbp
from flask import Blueprint,request,render_templatefrom exts import db,cursorbp=Blueprint("",__name__,url_prefix="/")@bp.route('/customer_on_probation')def CoP(): global results sql = "call CUSTOMER_ON_PROBATION" labels = ["LASTNAME", "FIRSTNAME", "EMAIL"] try: cursor.execute(sql) db.commit() results = cursor.fetchall() except: db.rollback() print(results) return render_template('list.html', labels=labels, content=results, title ="Cop", fORM_title="Customers on Probation")@bp.route('/number_of_passengers',methods=['GET','POST'])def NoP(): global results if request.method=="POST": sql = "call NUMBER_OF_PASSENGERS(" + str(request.form['input_num']) + ")" labels = ["Car ID", "Make", "Model", "Price Per Hour","Number of Passengers"] try: cursor.execute(sql) db.commit() results = cursor.fetchall() temp = [] for i in range(len(results)): temp.append(list(results[i])) temp[i][3] = "$" + temp[i][3] results = temp except: db.rollback() if(results): return render_template('list.html', labels=labels, content=results, title="RT",form_title="Number of Passengers") return render_template('list.html',form_title="Number of Passengers")@bp.route('/popular_locations')def PL(): global results sql = "call POPULAR_LOCATIONS" labels = ["Location ID", "Street Address", "Telephone","Number of Rentals"] try: cursor.execute(sql) db.commit() results = cursor.fetchall() except: db.rollback() print(results) return render_template('list.html', labels=labels, content=results, title="PL",form_title="Popular Locations")@bp.route('/rental_trends')def RT(): global results sql = "call RENTAL_TRENDS" labels = ["Make", "Model", "Student?","Number of Times Rented"] try: cursor.execute(sql) db.commit() results = cursor.fetchall() ans = [] for i in range(len(results)): ans.append(list(results[i])) if ans[i][2]==1: ans[i][2] = "YES" else: ans[i][2] = "NO" results = ans except: db.rollback() print(results) return render_template('list.html', labels=labels, content=results, title="RT",form_title="Rental Trends")@bp.route('/update_price',methods=['GET','POST'])def UP(): if request.method == "POST": # print("1") # print("2") pph_update = 0.5 ppd_update = 5 sql1 = "update car set pph = pph + " + str(pph_update) sql2 = "update car set ppd = ppd + " + str(ppd_update) cursor.execute(sql1) db.commit() cursor.execute(sql2) db.commit() sql = "select * from car" labels = ["ID","MAKE","MODEL","PASSENGERS","DESCRIPTION","PPH","PPD"] cursor.execute(sql) db.commit() results = cursor.fetchall() return render_template('list.html', labels=labels, content=results, title="UP",form_title="Current Car Information")@bp.route('/update_price_history')def UPH(): sql = "select * from price_log" cursor.execute(sql) db.commit() labels = ["Change ID","Car ID","Price per hour change","Price per day change","Update time"] results = cursor.fetchall() return render_template('list.html', labels=labels, content=results, title="UP",form_title="Update Price")@bp.route('/')@bp.route('/index')def yewu(): return render_template("shouye.html")@bp.route('/add_price',methods=['GET','POST'])def addPrice2(): if request.method == "POST": # print("1") # print("2") pph_update = 0.5 ppd_update = 5 sql1 = "update car set pph = pph + " + str(pph_update) sql2 = "update car set ppd = ppd + " + str(ppd_update) # print(sql1) # print(sql2) cursor.execute(sql1) # print("3") db.commit() cursor.execute(sql2) db.commit() sql = "select * from car" labels = ["ID","MAKE","MODEL","PASSENGERS","DESCRIPTION","PPH","PPD"] cursor.execute(sql) db.commit() # "INSERT INTO `price_log`(`ID`, `CAR_ID`, `PPH_CHANGE`, `PPD_CHANGE`, `UPDATE_TIME`) VALUES ('1','','[value-3]','[value-4]','[value-5]')" results = cursor.fetchall() return render_template('list.html', labels=labels, content=results, title="add_price",form_title="Current Car Information")
Download Font Awesome Free or Pro | Font Awesome
自己随便下载几张图片
Car share reservation
软考职称历年真题下载
-
2023下半年-信息系统项目管理师-真题考点汇总(完整版)
164.2 KB
查看
-
2023年下半年信息系统项目管理师第一、二批次各科目真题考点整理(考友回忆版)
143.67 KB
查看
-
2023上半年软考高级《信息系统项目管理师》真题答案(抢先版)
500.26 KB
查看
-
2022年下半年软考高级职称考试考情分析
823.36 KB
查看
-
2022年下半年软考高级职称考试真题
569.84 KB
查看
软考职称资料下载
-
2023下半年-系统集成项目管理工程师-真题考点汇总(完整版)
143.91 KB
查看
-
2023年下半年系统集成项目管理工程师第一、二、三批次真题考点整理(考友回忆版)
183.71 KB
查看
-
2023年上半年软考中级《系统集成项目管理工程师》-基础知识-考试真题及答案
644.84 KB
查看
-
2023年上半年软考中级《系统集成项目管理工程师》-应用技术-考试真题及答案
314.7 KB
查看
-
2023年下半年第一二批次系统集成项目管理工程师《案例分析》真题考点
115.57 KB
查看
热门wiki
近期文章
推荐阅读
-
sql如何在表中增加一列
2024-06-06
-
sql如何断开数据库的使用
2024-06-06
-
navicat怎么连sqlserver
2024-06-05
-
sql添加语句怎么写
2024-06-04
-
SQL Server中的镜像和Always On之间有什么区别
2024-06-04
-
描述SQL Server中的审核功能
2024-06-03
-
描述在SQL Server中如何设计和管理大型数据仓库
2024-06-03
-
如何在SQL Server环境中有效地管理和优化内存使用
2024-06-03
-
SQL Server中使用表变量与临时表的差异及适用场景
2024-06-04
-
在SQL Server中如何优化存储过程
2024-06-03
热门问答
-
1
回答
如何调试操作系统的错误?
操作系统
2023-11-15发布
-
1
回答
2023-11-15发布
-
1
回答
如何实现操作系统的内存管理?
操作系统
2023-11-15发布
-
1
回答
2023-11-15发布
-
1
回答
2023-11-15发布
-
1
回答
ASP中的数据验证和数据校验有什么不同?
ASP.NET
2023-11-15发布
-
1
回答
ASP中的ADO对象和DAO对象有什么区别和使用方法?
ASP.NET
2023-11-15发布
-
1
回答
2023-11-15发布
-
1
回答
2023-11-15发布
-
1
回答
2023-11-15发布
0