def post(self): form = request.form title = form.get("title") tags = form.get("tags") if tags: tags = tags.split(",") else: tags = [ ] cls = form.get("cls","undefine") context = form.get("context") publish = form.get("publish", False) bd = BlogData(STOREPATH) bd.add(title, context, tags, cls, publish) return "sucess!"
def POST(self): form = json.loads(request.data) tex = form.get("tex", " ") Id = setid() dir_path = os.path.join(STOREPATH,str(Id)) if os.path.isdir(dir_path): return "-1" #路径重复 os.mkdir(dir_path) file_path = os.path.join(dir_path, "index.md") with open(file_path, "w") as fp: fp.write(tex) (infos, tex) = get_info(file_path) BD = BlogData(STOREPATH) return BD.add(str(Id), infos, tex)