routes.py 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #!/usr/bin/env python3
  2. from flask import render_template, url_for
  3. from app import app
  4. from flask import request, jsonify
  5. from flask_restful import Resource, Api
  6. import pymysql
  7. @app.route("/")
  8. @app.route("/index")
  9. def index():
  10. usr = { "username":"clementine", "content" : "index" }
  11. return render_template( usr["content"] + '.html', title='home', user=usr)
  12. @app.route("/manage_card")
  13. def manage_card():
  14. usr = { "username":"clementine" }
  15. return render_template( 'manage_card.html', title='home', user=usr)
  16. @app.route("/manage_user")
  17. def manage_user():
  18. usr = { "username":"clementine" }
  19. return render_template( 'manage_user.html', title='home', user=usr)
  20. @app.route("/reissue_card")
  21. def reissue_card():
  22. usr = { "username":"clementine" }
  23. return render_template( 'reissue_card.html', title='home', user=usr)
  24. @app.route("/recycle_card")
  25. def recycle_card():
  26. usr = { "username":"clementine" }
  27. return render_template( 'recycle_card.html', title='home', user=usr)
  28. @app.route("/add_card_block")
  29. def add_card_block():
  30. usr = { "username":"clementine" }
  31. return render_template( 'add_card_block.html', title='home', user=usr)
  32. @app.route("/process_pending_card")
  33. def process_pending_card():
  34. usr = { "username":"clementine" }
  35. return render_template( 'process_pending_card.html', title='home', user=usr)
  36. @app.route("/search")
  37. def search():
  38. usr = { "username":"clementine" }
  39. return render_template( 'search.html', title='home', user=usr)
  40. @app.route("/help")
  41. def help():
  42. usr = { "username":"clementine" }
  43. return render_template( 'help.html', title='home', user=usr)
  44. ###
  45. class Database:
  46. def __init__(self):
  47. host = "127.0.0.1"
  48. user = "bus"
  49. password = ""
  50. db = "busdb"
  51. self.con = pymysql.connect(host=host, user=user, db=db, cursorclass=pymysql.cursors.DictCursor)
  52. self.cur = self.con.cursor()
  53. def ok(self):
  54. self.cur.execute("select rulename from rule_class where id = %s", 1)
  55. res = self.cur.fetchall()
  56. return res
  57. #@app.route("/api/v1/card")
  58. #def api_card():
  59. #
  60. # print(request.args)
  61. # param = request.args
  62. #
  63. # cardid = param.get("id")
  64. # mag_token = param.get("mag_token")
  65. # rfid_token = param.get("rfid_token")
  66. #
  67. # db = Database()
  68. # ok = db.ok()
  69. #
  70. # print(ok)
  71. #
  72. # if cardid:
  73. # print("cardid:", cardid)
  74. # elif mag_token:
  75. # print("mag:", mag_token)
  76. # elif rfid_token:
  77. # print("rfid:", rfid_token)
  78. #
  79. #
  80. # return jsonify({ "message": "card not implemented"})
  81. #
  82. #@app.route("/api/v1/user")
  83. #def api_user():
  84. # return jsonify({ "message": "user not implemented"})
  85. #
  86. #@app.route("/api/v1/pass")
  87. #def api_pass():
  88. # return jsonify({ "message": "pass not implemented"})
  89. #
  90. #@app.route("/api/v1/group")
  91. #def api_group():
  92. # return jsonify({ "message": "group not implemented"})