#!/usr/bin/env python3 from flask import render_template, url_for from app import app from flask import request, jsonify from flask_restful import Resource, Api import pymysql @app.route("/") @app.route("/index") def index(): usr = { "username":"clementine", "content" : "index" } return render_template( usr["content"] + '.html', title='home', user=usr) @app.route("/manage_card") def manage_card(): usr = { "username":"clementine" } return render_template( 'manage_card.html', title='home', user=usr) @app.route("/manage_user") def manage_user(): usr = { "username":"clementine" } return render_template( 'manage_user.html', title='home', user=usr) @app.route("/reissue_card") def reissue_card(): usr = { "username":"clementine" } return render_template( 'reissue_card.html', title='home', user=usr) @app.route("/recycle_card") def recycle_card(): usr = { "username":"clementine" } return render_template( 'recycle_card.html', title='home', user=usr) @app.route("/add_card_block") def add_card_block(): usr = { "username":"clementine" } return render_template( 'add_card_block.html', title='home', user=usr) @app.route("/process_pending_card") def process_pending_card(): usr = { "username":"clementine" } return render_template( 'process_pending_card.html', title='home', user=usr) @app.route("/search") def search(): usr = { "username":"clementine" } return render_template( 'search.html', title='home', user=usr) @app.route("/help") def help(): usr = { "username":"clementine" } return render_template( 'help.html', title='home', user=usr) ### class Database: def __init__(self): host = "127.0.0.1" user = "bus" password = "" db = "busdb" self.con = pymysql.connect(host=host, user=user, db=db, cursorclass=pymysql.cursors.DictCursor) self.cur = self.con.cursor() def ok(self): self.cur.execute("select rulename from rule_class where id = %s", 1) res = self.cur.fetchall() return res #@app.route("/api/v1/card") #def api_card(): # # print(request.args) # param = request.args # # cardid = param.get("id") # mag_token = param.get("mag_token") # rfid_token = param.get("rfid_token") # # db = Database() # ok = db.ok() # # print(ok) # # if cardid: # print("cardid:", cardid) # elif mag_token: # print("mag:", mag_token) # elif rfid_token: # print("rfid:", rfid_token) # # # return jsonify({ "message": "card not implemented"}) # #@app.route("/api/v1/user") #def api_user(): # return jsonify({ "message": "user not implemented"}) # #@app.route("/api/v1/pass") #def api_pass(): # return jsonify({ "message": "pass not implemented"}) # #@app.route("/api/v1/group") #def api_group(): # return jsonify({ "message": "group not implemented"})