55,000원
다른 수강생들이 자주 물어보는 질문이 궁금하신가요?
- 해결됨남박사의 파이썬으로 실전 웹사이트 만들기
현재 구글검색 무한스크롤변경 문의합니다
게시판만들기- 글리스트에서 3분:13초가량 현재 구글은 무한스크롤방식으로 바뀌었던데 page를 어떻게 처리해야하나요? 그냥 똑같이 써도되려나요?
- 미해결남박사의 파이썬으로 실전 웹사이트 만들기
몽고디비아틀라스로 추가 공부해서 올립니다.
https://bumychoi.tistory.com/37
- 미해결남박사의 파이썬으로 실전 웹사이트 만들기
IIS 500.19에러
구글로 먼저 배포 해보고 잘 되서 IIS로 배포해보려고 하는데다음과 같이 나옵니다handler도 Allow로 바꿨고web.config는 그대로 복사하고 경로도 확인했는데 뭐가 문제일까요...ㅠㅜㅠ
- 미해결남박사의 파이썬으로 실전 웹사이트 만들기
버전 문제도 수정했는데 결과가 안나옵니다.
{% with messages = get_flashed_messages() %} {% if messages %} <script> alert(" {{messages[-1]}}"); </script> {% endif %} {% endwith %} <table> <form name="form" action="/join" method="POST"> <thead> <caption>회원가입</caption> </thead> <tbody> <tr> <td>이름</td> <td><input type="text" name="name"></td> </tr> <tr> <td>이메일</td> <td><input type="text" name="email"></td> </tr> <tr> <td>비번</td> <td><input type="password" name="pass"></td> </tr> <tr> <td>비번확인</td> <td><input type="password" name="pass2"></td> </tr> <tr> <td colspan="2"><input type="submit" value="가입하기"></td> </tr> </tbody> </form> </table>from flask import Flask from flask import request,redirect,url_for from flask import render_template, abort from flask_pymongo import PyMongo from datetime import datetime from flask import flash from bson.objectid import ObjectId import time import math app = Flask(__name__) app.config["MONGO_URI"]="mongodb://localhost:27017/myweb" mongo = PyMongo(app) @app.template_filter("formatdatetime") def format_datetime(value): if value is None: return "" now_timestemp = time.time() offset = datetime.fromtimestamp(now_timestemp)-datetime.utcfromtimestamp(now_timestemp) value = datetime.fromtimestamp((int(value)/1000))+offset return value.strftime('%Y-%m-%d %H:%M:%S') @app.route("/list") def lists(): # 페이지 값(값이 없는 경우 기본값은 1) page = request.args.get("page",1,type=int) #한페이지당 몇개의 개시물을 출력할지 limit = request.args.get("limit",5,type=int) search = request.args.get("search",-1,type=int) keyword = request.args.get("keyword",type=str) #최종적으로 완성된 쿼리를 만들 변수 query = {} # 검색아 상태를 추가할 리스트 변수 search_list=[] if search ==0: search_list.append({"title":{"$regex":keyword}}) elif search == 1: search_list.append({"contents":{"regex":keyword}}) elif search == 2: search_list.append({"title":{"$regex":keyword}}) search_list.append({"contents":{"$regex":keyword}}) elif search ==3: search_list.append({"name":{"$regex":keyword}}) # 검색 대상이 한개라고 존재할 겨우 query 변수에 $or 리스트를 쿼리 합니다. if len(search_list)>0: query={"$or":search_list} print(query) board = mongo.db.board datas = board.find(query).skip((page - 1)*limit).limit(limit) # 개시물에 총 갯수(수정됨) tot_count = board.count_documents(query) # 마지작 페이지의 수를 구합니다. last_page_num = math.ceil(tot_count / limit) # 페이지 블럭을 5개씩 표기 block_size = 5 # 현재블럭의 위치 block_num = int((page - 1)/block_size) # 블럭의 시작 위치 block_start = int((block_size * block_num) +1) # 블럭의 끝 위치 block_last = math.ceil(block_start + (block_size - 1)) return render_template( "list.html", datas=list(datas), limit=limit, page=page, block_start=block_start, block_last=block_last, last_page_num=last_page_num, search=search, keyword=keyword) @app.route("/view/<idx>") def board_view(idx): # idx = request.args.get("idx") 펜시유알엘 if idx is not None: page = request.args.get("page") search = request.args.get("search") keyword = request.args.get("keyword") board = mongo.db.board data = board.find_one({"_id":ObjectId(idx)}) if data is not None: result={ "id":data.get("_id"), "name":data.get("name"), "title":data.get("title"), "contents":data.get("contents"), "pubdate":data.get("pubdate"), "view":data.get("view") } print(id) return render_template("view.html",result=result, page=page, search=search, keyword=keyword) return abort(404) @app.route("/write",methods=['GET','POST']) def board_write(): if request.method=="POST": name = request.form.get("name") title = request.form.get("title") contents = request.form.get("contents") print(name,title,contents) current_utc_time = round(datetime.utcnow().timestamp() *1000) board = mongo.db.board post={ "name":name, "title": title, "contents":contents, "pubdate":current_utc_time, "view":0, } x = board.insert_one(post) print(x.inserted_id) return redirect(url_for("board_view",idx=x.inserted_id)) else: return render_template("write.html") @app.route("/join",methods=["POST","GET"]) def menber_join(): if request.method =="POST": name = request.form.get("name",type=str) email = request.form.get("email",type=str) pass1 = request.form.get("pass",type=str) pass2 = request.form.get("pass2",type=str) if name is None or email is None or pass1 is None or pass2 is None: flash ("입력되지 않은 값이 있습니다.") return render_template("join.html") if pass1 != pass2: flash("비밀번호가 일치 하지않습니다.") return render_template("join.html") members = mongo.db.menbers # 이부분 버전 수정됨 cnt = members.count_documents({"email":email}) if cnt > 0: flash("중복된 이메일 주소입니다.") return render_template("join.html") current_utc_time = round(datetime.utcnow().timestamp()*1000) post ={ 'name':name, 'email':email, 'pass':pass1, "joindate":current_utc_time, "logtime":"", "logincount":0, } members.insert_one(post) return "" else: return render_template("join.html") if __name__ == "__main__": app.run(host="0.0.0.0",debug=True,port=5000)
- 미해결남박사의 파이썬으로 실전 웹사이트 만들기
데이터베이스 저장관련 질문입니다.
이름, 나이, 거주지... 등등 모든 데이터가 동일할때 저장하지 않게 하는 명령어가 따로 있을까요??없다면, if와 for문을 써서 대조 후 없다면 저장 이런식으로 코드를 짜야하나요?
- 미해결남박사의 파이썬으로 실전 웹사이트 만들기
test가 생기지 않습니다.
python test.py 실행하고 나서 studio 3t for mogoDB에 들어가도 test가 생기지 않습니다. 혹시 이유를 알 수 있을지 여쭤봅니다.
- 미해결남박사의 파이썬으로 실전 웹사이트 만들기
파일 첨부하면 선택한 파일 이름이 나올 수 있게 할 수 없나요?
위 화면에서 파일 첨부하고 나서 이름이 나오면 좋을 것 같은데... 어렵네요</script> <form name="form" method="POST" action="{{url_for('board.board_write')}}" onsubmit="return checkForm()" enctype="multipart/form-data"> <input type="hidden" name="csrf_token" value="{{csrf_token()}}"> <div class="form-group"> <label for="name">작성자</label> <input class="form-control" id="name" type="text" name="name" value="{{session['name']}}" readonly> </div> <div class="form-group"> <label for="title">제목</label> <input class="form-control" type="text" name="title" id="title" placeholder="제목을 입력하세요."> </div> <div class="form-group"> <label for="maintd">정비날짜</label> <input class="form-control" type="datetime-local" name="maintd" id="maintd" placeholder="정비 날짜를 입력하세요."> </div> <div class="form-group"> <label for="contents">내용</label> <textarea rows="8" class="form-control" name="contents" id="summernote" placeholder="내용을 입력하세요."></textarea> </div> <div class="custom-file"> <input class="custom-file-input" id="customFile" type="file" name="attachfile"> <label class="custom-file-label" for="customFile">파일선택</label> </div> <br><br> <a class="btn btn-primary" href="{{url_for('board.lists', page=page, search=search, keyword=keyword)}}">리스트</a> <br><br> <div class="text-center"><input class="btn btn-primary" type="submit" value="작성하기"></div> </form> {% endblock %}
- 미해결남박사의 파이썬으로 실전 웹사이트 만들기
로그아웃했다가 다시 로그인하면 다음과 같은 오류메세지가 뜨는데요
werkzeug.routing.exceptions.BuildError: Could not build url for endpoint 'member.lists'. Did you mean 'board.lists' instead?
- 미해결남박사의 파이썬으로 실전 웹사이트 만들기
구글 클라우드에서 static 폴더 경로 설정 문제
안녕하세요 좋은 강의 잘 듣고 있습니다 구글 클라우드에서 docker file을 실행했을때 static 폴더에 있는 image file 동영상 파일이 없다고 나오는데요 image 파일 동영상 파일을 불러오는(rendering하는) html 파일에서 static 폴더내 이미지 동영상 파일 경로를 어떻게 설정해야하는지 궁금합니다설명 부탁드립니다 감사합니다
- 해결됨남박사의 파이썬으로 실전 웹사이트 만들기
mac 설치방법도 알려주세요 ㅠㅠ studio 3t 에서 localhost 커넥트가 안됨
(사진)
- 미해결남박사의 파이썬으로 실전 웹사이트 만들기
왜 list창으로 넘어가지 않나요?
로그인, 글쓰기 모두 이상 없는데... list 클릭 시 하기처럼 Error 가 발생합니다OS는 윈도우10 Mongodb 4.2.22 입니다파일 "D:\PM_WebService\venv\Lib\site-packages\flask\app.py", 2551 행, 안으로 __call__ def __call__(self, environ: dict, start_response: t.Callable) -> t.Any: """The WSGI server calls the Flask application object as the WSGI application. This calls :meth:`wsgi_app`, which can be wrapped to apply middleware. """ return self.wsgi_app(environ, start_response) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^파일 "D:\PM_WebService\venv\Lib\site-packages\flask\app.py", 2531 행, 안으로 wsgi_app try: ctx.push() response = self.full_dispatch_request() except Exception as e: error = e response = self.handle_exception(e) ^^^^^^^^^^^^^^^^^^^^^^^^ except: # noqa: B001 error = sys.exc_info()[1] raise return response(environ, start_response) finally:파일 "D:\PM_WebService\venv\Lib\site-packages\flask\app.py", 2528 행, 안으로 wsgi_app ctx = self.request_context(environ) error: t.Optional[BaseException] = None try: try: ctx.push() response = self.full_dispatch_request() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ except Exception as e: error = e response = self.handle_exception(e) except: # noqa: B001 error = sys.exc_info()[1]파일 "D:\PM_WebService\venv\Lib\site-packages\flask\app.py", 1825 행, 안으로 full_dispatch_request request_started.send(self) rv = self.preprocess_request() if rv is None: rv = self.dispatch_request() except Exception as e: rv = self.handle_user_exception(e) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ return self.finalize_request(rv) def finalize_request( self, rv: t.Union[ft.ResponseReturnValue, HTTPException],파일 "D:\PM_WebService\venv\Lib\site-packages\flask\app.py", 1823 행, 안으로 full_dispatch_request try: request_started.send(self) rv = self.preprocess_request() if rv is None: rv = self.dispatch_request() ^^^^^^^^^^^^^^^^^^^^^^^ except Exception as e: rv = self.handle_user_exception(e) return self.finalize_request(rv) def finalize_request(파일 "D:\PM_WebService\venv\Lib\site-packages\flask\app.py", 1799 행, 안으로 dispatch_request and req.method == "OPTIONS" ): return self.make_default_options_response() # otherwise dispatch to the handler for that endpoint view_args: t.Dict[str, t.Any] = req.view_args # type: ignore[assignment] return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ def full_dispatch_request(self) -> Response: """Dispatches the request and on top of that performs request pre and postprocessing as well as HTTP exception catching and error handling.파일 "D:\PM_WebService\run.py", 137 행, 안으로 lists query = {"$or": search_list} board = mongo.db.board datas = board.find(query).skip((page-1) * limit).limit(limit) tot_count = board.find(query).count() ^^^^^^^^^^^^^^^^^^^^^^^ last_page_num = math.ceil(tot_count / limit) block_size = 5 block_num = int((page-1) / block_size) block_start = int((block_size * block_num) + 1)
- 미해결남박사의 파이썬으로 실전 웹사이트 만들기
전체 소스 어디서 down 받나요?
인강 들으면서 소스 down 받았는데... 전체 소스를 설치 하고 싶은데... 어디서 받나요?
- 미해결남박사의 파이썬으로 실전 웹사이트 만들기
로그인 후 list.html 로 전환 안되고 에러
AttributeErrorAttributeError: 'Cursor' object has no attribute 'count'Traceback (most recent call last)File "C:\Users\hongbh\AppData\Roaming\Python\Python311\site-packages\flask\app.py", line 2551, in __call__return self.wsgi_app(environ, start_response) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "C:\Users\hongbh\AppData\Roaming\Python\Python311\site-packages\flask\app.py", line 2531, in wsgi_appresponse = self.handle_exception(e) ^^^^^^^^^^^^^^^^^^^^^^^^File "C:\Users\hongbh\AppData\Roaming\Python\Python311\site-packages\flask\app.py", line 2528, in wsgi_appresponse = self.full_dispatch_request() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "C:\Users\hongbh\AppData\Roaming\Python\Python311\site-packages\flask\app.py", line 1825, in full_dispatch_requestrv = self.handle_user_exception(e) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "C:\Users\hongbh\AppData\Roaming\Python\Python311\site-packages\flask\app.py", line 1823, in full_dispatch_requestrv = self.dispatch_request() ^^^^^^^^^^^^^^^^^^^^^^^File "C:\Users\hongbh\AppData\Roaming\Python\Python311\site-packages\flask\app.py", line 1799, in dispatch_requestreturn self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "D:\PM_WebService\main\member.py", line 23, in member_joincnt = members.find({"email": email}).count() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^AttributeError: 'Cursor' object has no attribute 'count'The debugger caught an exception in your WSGI application. You can now look at the traceback which led to the error.To switch between the interactive traceback and the plaintext one, you can click on the "Traceback" headline. From the text traceback you can also create a paste of it. For code execution mouse-over the frame you want to debug and click on the console icon on the right side.You can execute arbitrary Python code in the stack frames and there are some extra helpers available for introspection:dump() shows all variables in the framedump(obj) dumps all that's known about the object
- 미해결남박사의 파이썬으로 실전 웹사이트 만들기
search = request.args.get('search', -1, type=int)
search = request.args.get('search', -1, type=int)에서 -1의 의미를 정확히 모르겠네요. 다시 한번 예를 들어 설명해 주셨으면 감사하겠습니다.
- 미해결남박사의 파이썬으로 실전 웹사이트 만들기
{% for i in range(block_start, block_last + 1 ) %} 에서
{% for i in range(block_start, block_last + 1 ) %} 에서block_last + 1을 해주는 이유가 궁금합니다.
- 해결됨남박사의 파이썬으로 실전 웹사이트 만들기
@app.route("/") 질문
남박사님 수업 재밌고 열심히 듣고 있습니다.우선은 웹프로그래밍을 이해하기보다는 "구현한다"라는 목표를 갖고 있고, 생소한 개념은 제가 따로 공부해야할 부분인거 같습니다.질문1: @app.route("/")에서 "/"라는 것은 (/아래의 주소가 없으므로), 로컬호스트 주소인가요? 질문2: route 밑에서 index()라는 함수를 정의하고 "헬로 파이썬"을 return 하겠다라는 뜻인가요?index 함수를 정의했지만, index함수를 콜 하지 않았는데 return값이 나와서 뭔가 어색합니다.
- 미해결남박사의 파이썬으로 실전 웹사이트 만들기
게시판 띄우는게 안돼요..
from flask import Flask from flask import request from flask import render_template app = Flask(__name__) @app.route("/write", methods=['GET','POST']) def board_write(): if request.method == "POST": name = request.form.get("name") title = request.form.get("title") contents = request.form.get("contents") return "" else: return render_template("write.html") if __name__ == "__main__": app.run(host="0.0.0.0", debug=True, port=9000)일단 이렇게 코드를 치고, 이렇게 나와서, https://127.0.0.1:9000으로 들어가서 http://localhost:9000/write로 들어갔는데 이런식으로만 뜨네요... 자꾸 왜 이러는 거죠?? 강사님 살려주세요..
- 미해결남박사의 파이썬으로 실전 웹사이트 만들기
게시판 띄우는게 안돼요..
from flask import Flask from flask import request from flask import render_template app = Flask(__name__) @app.route("/write", methods=['GET','POST']) def board_write(): if request.method == "POST": name = request.form.get("name") title = request.form.get("title") contents = request.form.get("contents") return "" else: return render_template("write.html") if __name__ == "__main__": app.run(host="0.0.0.0", debug=True, port=9000)일단 이렇게 코드를 치고, 이렇게 나와서, https://127.0.0.1:9000으로 들어가서 http://localhost:9000/write로 들어갔는데 이런식으로만 뜨네요... 자꾸 왜 이러는 거죠?? 강사님 살려주세요..
- 미해결남박사의 파이썬으로 실전 웹사이트 만들기
robo3T 설치 문제 : robo3T는 중지된 시스템.. 어떻게 진행해야하는가
mongoDB설치하는 강의에서 문제가 발생했습니다.mongoDB는 설치가 완료됐습니다. 하지만 robo3T설치하는데 문제가 생겼습니다. robomongo.org사이트에서 지금은 robo3T와 studio3T이 구분되어 있지 않습니다.더 이상 robo3T는 운영되지 않고 있더군요. 또한 studio3T는 유로 사이트 입니다. robo3T를 더이상 다운받지 못하는 상황에서 어떻게 진행해야 하죠?? 이것이 진행되지 않으면 더이상 강의를 진행하기가 어려워 보입니다. 답변 부탁드립니다.
- 미해결남박사의 파이썬으로 실전 웹사이트 만들기
studio 3t로 mongo db접속 방법
프로젝트를 Docker 이미지로 만들어서 배포하기16분8초 입니다 영상을 보면 mongo 컨테이너가 잘 실행되고 있습니다.해당 컨테이너에studio 3t로 접속을 하고싶은데studio 3t에서 mongo 컨테이너를 접속하려면(mongo 컨테이너 포트가 16000:27017이니까)제아이이피:16000이런식으로 주소를 만들어서 접속하는것인지궁금합니다 만약 접속이 가능하다면,아이디나 패스워드는 정한적이 없는데, 아이디 패스워드 없이 접속이 가능한것인지 궁금합니다