python实现图书借阅系统

所属分类: 脚本专栏 / python 阅读数: 861
收藏 0 赞 0 分享

本文实例为大家分享了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用5行代码写一个自定义简单二维码

今天小编就为大家分享一篇关于Python用5行代码写一个自定义简单二维码的文章,小编觉得内容挺不错的,现在分享给大家,具有很好的参考价值,需要的朋友一起跟随小编来看看吧
收藏 0 赞 0 分享

python中将正则过滤的内容输出写入到文件中的实例

今天小编就为大家分享一篇python中将正则过滤的内容输出写入到文件中的实例,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
收藏 0 赞 0 分享

一看就懂得Python的math模块

今天小编就为大家分享一篇关于Python的math模块,小编觉得内容挺不错的,现在分享给大家,具有很好的参考价值,需要的朋友一起跟随小编来看看吧
收藏 0 赞 0 分享

python按时间排序目录下的文件实现方法

今天小编就为大家分享一篇python按时间排序目录下的文件实现方法,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
收藏 0 赞 0 分享

python检测文件夹变化,并拷贝有更新的文件到对应目录的方法

今天小编就为大家分享一篇python检测文件夹变化,并拷贝有更新的文件到对应目录的方法。具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
收藏 0 赞 0 分享

通过python将大量文件按修改时间分类的方法

今天小编就为大家分享一篇通过python将大量文件按修改时间分类的方法,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
收藏 0 赞 0 分享

解决python中os.listdir()函数读取文件夹下文件的乱序和排序问题

今天小编就为大家分享一篇解决python中os.listdir()函数读取文件夹下文件的乱序和排序问题,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
收藏 0 赞 0 分享

python 对key为时间的dict排序方法

今天小编就为大家分享一篇python 对key为时间的dict排序方法,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
收藏 0 赞 0 分享

使用Python抓取豆瓣影评数据的方法

今天小编就为大家分享一篇关于使用Python抓取豆瓣影评数据的方法,小编觉得内容挺不错的,现在分享给大家,具有很好的参考价值,需要的朋友一起跟随小编来看看吧
收藏 0 赞 0 分享

Python实现Dijkstra算法

今天小编就为大家分享一篇关于Python实现Dijkstra算法,小编觉得内容挺不错的,现在分享给大家,具有很好的参考价值,需要的朋友一起跟随小编来看看吧
收藏 0 赞 0 分享
查看更多