rename2 [Python] 업데이트하기(input, format, rename) [생활코딩] 활용 - 수정 구현 pageId값 유무에 따라 update 버튼 출력 index.py #!/usr/local/bin/python3 print("content-type:text/html; charset=UTF-8\n") import cgi,os files = os.listdir('data') liststr = '' for item in files: liststr = liststr + '{name}'.format(name=item) form = cgi.FieldStorage() if 'id' in form: pageId = form["id"].value description = open('data/'+pageId).read() update_link = 'update'.format(pageid=p.. 2020. 8. 23. [Nodejs] 파일명 변경하고 저장 - rename(), writeFile() [생활코딩] App - 글수정 - 수정된 내용 저장 fs.rename(oldPath, newPath, callback) - 파일명 변경하기 fs.writeFile(filename, data, [options], callback) - 파일 저장하기 if(pathname === '/update_process'){ // submit했을 때 이동되는 페이지 var body ''; request.on('data', function(data){ body = body+data; // 들어온 데이터 body에 저장 }); request.on('end', function(){ // data가 다 들어오면 callback함수 실행 var post = qs.parse(body); var id = post.id; // 변경될.. 2020. 8. 4. 이전 1 다음 반응형