python实现图书借阅系统


Posted in Python onFebruary 20, 2019

本文实例为大家分享了python实现图书借阅系统的具体代码,供大家参考,具体内容如下

部分代码:

from flask import Flask,render_template
from flask import request
from DB import createdb
from flask import session

app = Flask(__name__)
app.config['SECRET_KEY'] = '123456'

# 首页-->登录页面
@app.route('/')
def hello_world():
  return render_template('login.html')

# 注册页面
@app.route('/showregister')
def showregister():
  return render_template('register.html')

# 登录页面提交信息
@app.route('/login',methods=['GET','POST'])
def login():
  username = request.form.get('username')
  stuid = request.form.get('password') # 学号为密码
  flag = createdb.selectStu(stuid,username)
  if flag:
    session['username'] = username
    session['stuid'] = stuid
    return render_template('index.html', stuid=stuid, username=username)
  else:
    return render_template('login.html')

# 注册页面提交信息
@app.route('/register',methods=['GET','POST'])
def register():
  username = request.form.get('username')
  stuid = request.form.get('password')# 学号为密码
  return createdb.insert(stuid,username)

# 显示书籍信息页面
@app.route('/ShowBook')
def ShowBook():
  return createdb.queryAllBook()

# 显示添加书籍页面
@app.route('/AddBook')
def AddBook():
  return render_template('AddBook.html')

# 添加书籍信息
@app.route('/Add',methods=['GET','POST'])
def Add():
  bookName = request.form.get('bookname')
  bookAuthor = request.form.get('author')
  return createdb.addBook(bookName,bookAuthor)

# 显示借阅书籍信息
@app.route('/BorrowBook')
def BorrowBook():
  return createdb.queryBorrowBook()

# 显示借阅书籍信息
@app.route('/Borrow',methods=['GET','POSt'])
def Borrow():
  bookName = request.form.get('bookName')
  bookAuthor = request.form.get('bookAuthor')
  username = session.get('username')
  stuid = session.get('stuid')
  return createdb.Borrow(username,stuid,bookName,bookAuthor)

# 显示借阅书籍信息
@app.route('/ReturnBook',methods=['GET','POST'])
def ReturnBook():
  bookName = request.form.get("bookName")
  return createdb.ReturnBook(bookName)

# 显示借阅书籍信息
@app.route('/UserInfo')
def UserInfo():
  stuid = session.get('stuid')
  username = session.get('username')
  return render_template('userInfo.html',stuid = stuid,username = username)


if __name__ == '__main__':
  app.run(debug=True)

源码下载:python实现图书借阅系统

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持三水点靠木。

Python 相关文章推荐
Python contextlib模块使用示例
Feb 18 Python
django 实现电子支付功能的示例代码
Jul 25 Python
Python WSGI的深入理解
Aug 01 Python
Flask之请求钩子的实现
Dec 23 Python
Django中celery执行任务结果的保存方法
Jul 12 Python
python重要函数eval多种用法解析
Jan 14 Python
python 装饰器功能与用法案例详解
Mar 06 Python
python实现飞船游戏的纵向移动
Apr 24 Python
Selenium元素定位的30种方式(史上最全)
May 11 Python
python中id函数运行方式
Jul 03 Python
python调用jenkinsAPI构建jenkins,并传递参数的示例
Dec 09 Python
Pandas自定义选项option设置
Jul 25 Python
python 调用钉钉机器人的方法
Feb 20 #Python
python钉钉机器人运维脚本监控实例
Feb 20 #Python
Python实现钉钉发送报警消息的方法
Feb 20 #Python
python给微信好友定时推送消息的示例
Feb 20 #Python
linux查找当前python解释器的位置方法
Feb 20 #Python
python 定时器,实现每天凌晨3点执行的方法
Feb 20 #Python
python爬取酷狗音乐排行榜
Feb 20 #Python
You might like
php 来访国内外IP判断代码并实现页面跳转
2009/12/18 PHP
php操作xml入门之cdata区段
2015/01/23 PHP
PHP中基本HTTP认证技巧分析
2015/03/16 PHP
从阿里妈妈发现的几个不错的表单验证函数
2007/09/21 Javascript
jQuery Clone Bug解决代码
2010/12/22 Javascript
固定表格行列(expression)在IE下适用
2013/07/25 Javascript
window.onload和$(function(){})的区别介绍
2013/10/30 Javascript
排序算法的javascript实现与讲解(99js手记)
2014/09/28 Javascript
jquery.form.js实现将form提交转为ajax方式提交的方法
2015/04/07 Javascript
jQuery实现的多屏图像图层切换效果实例
2015/05/07 Javascript
使用CamanJS在Web页面上处理图像的技巧
2015/08/18 Javascript
jQuery实现可编辑的表格实例讲解(2)
2015/09/17 Javascript
微信小程序使用第三方库Immutable.js实例详解
2016/09/27 Javascript
JS库之Three.js 简易入门教程(详解之一)
2017/09/13 Javascript
弱类型语言javascript中 a,b 的运算实例小结
2019/08/07 Javascript
vue v-for出来的列表,点击某个li使得当前被点击的li字体变红操作
2020/07/17 Javascript
[49:05]OG vs Newbee 2019DOTA2国际邀请赛淘汰赛 胜者组 BO3 第二场 8.21.mp4
2020/07/19 DOTA
python实现bucket排序算法实例分析
2015/05/04 Python
Django中对数据查询结果进行排序的方法
2015/07/17 Python
详解Python的Django框架中的中间件
2015/07/24 Python
Python中在脚本中引用其他文件函数的实现方法
2016/06/23 Python
用yum安装MySQLdb模块的步骤方法
2016/12/15 Python
在Python中实现shuffle给列表洗牌
2018/11/08 Python
ubuntu上安装python的实例方法
2019/09/30 Python
Python实现密码薄文件读写操作
2019/12/16 Python
Python解释器及PyCharm工具安装过程
2020/02/26 Python
解决PDF 转图片时丢文字的一种可能方式
2021/03/04 Python
记一次高分屏下canvas模糊问题
2020/02/17 HTML / CSS
实现向右循环移位
2014/07/31 面试题
SQL Server 2000数据库的文件有哪些,分别进行描述。
2015/11/09 面试题
麦当劳辞职信范文
2014/01/18 职场文书
高一学生期末评语
2014/04/25 职场文书
入党积极分子考察意见
2015/06/02 职场文书
女性健康知识讲座主持词
2015/07/04 职场文书
接收函
2019/04/22 职场文书
Python Matplotlib绘制两个Y轴图像
2022/04/13 Python