Example #1
0
File: groups.py Project: gsk727/git
class Group(View):
    """
    group
    """
    def __init__(self):
        pass


    def dispatch_request(self, name):
        """
        get groups
        """        

        return render_template("group.html", name=name)

app.add_url_rule("/groups/<name>", view_func = Group.as_view("group"))

@app.route("/file/<fname>.<ftype>")
def send_view(fname, ftype):
    
    if os.path.isfile("/home/gsk/%s.%s"%(fname, ftype)):
        return  send_file("/home/gsk/%s.%s"%(fname, ftype))
    else:
      abort(400)


class Groups(View):
    """
    groups
    """
    def __init__(self, name):
Example #2
0
                    "title":mname}}}, {"_id": 0})

        elif mname is not None and page != 0: # 显示所有的
            print  {"group":member, "magazines":{"$elemMatch":{"title":mname} }, "magazines.%s"%((page),):{"$exists":1 }}
            res = db.magezines.find_one({"group":member, "magazines":{"$elemMatch":{"title":mname} }, "magazines.%s"%((page),):{"$exists":1 }})
            if res is not None:
                res = res["magezines"][str[page]]
  
        print res
        if not res:
            return ""

        # if res.count() == 0:
        # 测试分页 
        # return json.dumps(list(res))         
        return json.dumps(list(res)) 
       # return render_template("magazine.html", res = res, mname = mname)

app.add_url_rule("/groups/<group_member>/magazine/<clientid>",
    view_func =  MagazineView.as_view("gmagazine"))

app.add_url_rule("/groups/<group_member>/magazine/<mname>/<clientid>",
    view_func =  MagazineView.as_view("gmagazine"))

app.add_url_rule("/groups/<group_member>/magazine/<mname>/<page>",
    view_func =  MagazineView.as_view("gmagazine"))

app.add_url_rule("/groups/<group_member>/<magezine>/<mname>/<page>/<clientid>",
        view_func= MagazineView.as_view("gmagazine"))