python實現(xiàn)圖書借閱系統(tǒng)
更新時間:2019年02月20日 11:33:04 作者:晚風潤的侯侯
這篇文章主要為大家詳細介紹了python實現(xiàn)圖書借閱系統(tǒng),具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了python實現(xiàn)圖書借閱系統(tǒng)的具體代碼,供大家參考,具體內容如下
部分代碼:
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實現(xiàn)圖書借閱系統(tǒng)
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關文章
Python中的shape[0]、shape[1]和shape[-1]使用方法
shape函數(shù)是Numpy中的函數(shù),它的功能是讀取矩陣的長度,比如shape[0]就是讀取矩陣第一維度的長度,這篇文章主要介紹了Python中的shape[0]、shape[1]和shape[-1]使用方法,需要的朋友可以參考下2023-07-07解決pycharm導入本地py文件時,模塊下方出現(xiàn)紅色波浪線的問題
這篇文章主要介紹了解決pycharm導入本地py文件時,模塊下方出現(xiàn)紅色波浪線的問題,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-06-06