
* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.
* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.
flask 로 간단한 crud 미니 프로젝트를 스터디원 분과 진행 하고있었습니다.
오류가 발생한 board api 를 수정하기 전에 확인해보던중 발생했습니다.
발생한 문제를 스터디원 분께 알렸고 같은코드를 pull 하여 원격화면으로 보면서
서로 실행해본 결과 스터디원분(Window) 는 잘 작동하였고 저(Mac) 은 작동하지 않았습니다.
어느 부분이 문제인지 찾기 어려워 질문남깁니다.




작성한 코드 및 에러 메세지
에러발생 코드입니다.
board.py
from flask import Blueprint, render_template, request, current_app, session
from werkzeug.utils import secure_filename
from pymongo import MongoClient
import datetime as dt
board = Blueprint('board', __name__)
client = MongoClient('mongodb+srv://gmakin36:vcAhbtS2O3CsZFxC@cocktail-cluster.zgihll4.mongodb.net/?retryWrites=true&w=majority')
db = client.kacktail
@board.route('/board')
def board_list():
result = list()
kacktail_list = list(db.board.find({},{'_id':False}))
count = 1
for a in kacktail_list:
doc = {
'title': a['title'],
'text': a['text'],
'images': a['images'],
'author': a['author'],
'count': count,
}
count = count+1
result.append(doc)
return render_template('user/main_page/index.html',kacktail_list = result)
@board.route('/board/save')
def board_create_get():
return render_template('user/main_page/board_create.html')
@board.route('/board/save', methods=["POST"])
def board_create_post():
title = request.form['title']
text = request.form['text']
img = request.files['img']
img_url = '/img/'+img.filename
createday = dt.datetime.now().replace(microsecond=0)
img.save(current_app.static_folder+'/img/'+img.filename)
doc = {
'title': title,
'text': text,
'images': img_url,
'author': '', #작성자는 로그인 기능 완료후 수정.
'create_day': createday,
'update_day': ''
}
db.board.insert_one(doc)
result = list()
kacktail_list = list(db.board.find({},{'_id':False}))
count = 1
for a in kacktail_list:
doc = {
'title': a['title'],
'text': a['text'],
'images': a['images'],
'author': a['author'],
'count': count,
}
count = count+1
result.append(doc)
return render_template('user/main_page/index.html',kacktail_list = result)
@board.route('/board/delete', methods=["POST"])
def board_delete_get():
return "게시판 삭제"
@board.route('/board/update', methods=["POST"])
def board_update_post():
return "게시판 수정"
@board.route('/board/update')
def board_update_get():
return "게시판 수정 화면"
board_create.html
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/x-icon" href="{{url_for('static', filename='/assets/favicon.ico')}}"/>
<title>게시글 생성</title>
</head>
<body>
<div style="margin: 0 auto; width: 900px;">
<div >
<div >
<div >
<form action="/board/save" method="post" enctype="multipart/form-data">
<!-- Project details-->
<div style="margin-bottom: 50px;">제목 : <input name="title" type="text" placeholder="제목"></div>
<div style="margin-bottom: 50px;">이미지 : <input name="img" type="file" value="default"></div>
<div style="margin-bottom: 50px;"><textarea name="text"style=" width:500px; height:100px; border: none;resize: none;" placeholder="내용 입력해주세요..."></textarea></div>
<div><input type="submit" value="게시글 생성하기"></div>
</form>
</div>
</div>
</div>
</body>
</html>
오류 발생 시, 작성한 코드 전체와 에러 메시지를 첨부해 주세요.
Tip 1) </> 아이콘을 눌러 코드박스를 만들어 보세요.
Tip 2) Ctrl+A(맥의 경우 Command+A) 단축키로 코드를 한 번에 선택할 수 있어요!
