커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
4-8강
undefined주차
북마크
이*빈
댓글
3
추천
0
조회수
16
조회수
16
답변 완료

* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.

* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.


초반까진 괜찮았는데 dbprac.py에서 몇 줄 복붙해오고 다시 localhost 창 열려고 하니까 실행이 안 되네요 ㅠㅠ

pip install certifi 도 쳤었어요



보고 계신 화면 전체를 캡처해 주시면

스파르타 즉문즉답

, 튜터님들이 빠르게 상황을 이해할 수 있어요.




source "/Users/suebe/Desktop/Sparta Coding/projects/02.mars/venv/bin/activate"
suebe@MacBook-Air 02.mars % source "/Users/suebe/Desktop/Sparta Coding/pr
ojects/02.mars/venv/bin/activate"
(venv) suebe@MacBook-Air 02.mars % "/Users/suebe/Desktop/Sparta Coding/pr
ojects/02.mars/venv/bin/python" "/Users/suebe/Desktop/Sparta Coding/proje
cts/02.mars/app.py"
 * Serving Flask app 'app'
 * Debug mode: on
Address already in use
Port 5000 is in use by another program. Either identify and stop that program, or start the server with a different port.
On macOS, try disabling the 'AirPlay Receiver' service from System Preferences -> Sharing.
(venv) suebe@MacBook-Air 02.mars % "/Users/suebe/Desktop/Sparta Coding/pr
ojects/02.mars/venv/bin/python" "/Users/suebe/Desktop/Sparta Coding/proje
cts/02.mars/app.py"
 * Serving Flask app 'app'
 * Debug mode: on
Address already in use
Port 5000 is in use by another program. Either identify and stop that program, or start the server with a different port.
On macOS, try disabling the 'AirPlay Receiver' service from System Preferences -> Sharing.
(venv) suebe@MacBook-Air 02.mars % "/Users/suebe/Desktop/Sparta Coding/pr
ojects/02.mars/venv/bin/python" "/Users/suebe/Desktop/Sparta Coding/proje
cts/02.mars/app.py"
 * Serving Flask app 'app'
 * Debug mode: on
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
 * Running on all addresses (0.0.0.0)
 * Running on http://127.0.0.1:5001
 * Running on http://192.168.35.163:5001
Press CTRL+C to quit
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 586-429-204
^C%                                                                      
(venv) suebe@MacBook-Air 02.mars % "/Users/suebe/Desktop/Sparta Coding/pr
ojects/02.mars/venv/bin/python" "/Users/suebe/Desktop/Sparta Coding/proje
cts/02.mars/app.py"
 * Serving Flask app 'app'
 * Debug mode: on
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
 * Running on all addresses (0.0.0.0)
 * Running on http://127.0.0.1:5001
 * Running on http://192.168.35.163:5001
Press CTRL+C to quit
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 586-429-204
^C%                                                                      
(venv) suebe@MacBook-Air 02.mars % "/Users/suebe/Desktop/Sparta Coding/pr
ojects/02.mars/venv/bin/python" "/Users/suebe/Desktop/Sparta Coding/proje
cts/02.mars/app.py"
 * Serving Flask app 'app'
 * Debug mode: on
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
 * Running on all addresses (0.0.0.0)
 * Running on http://127.0.0.1:5001
 * Running on http://192.168.35.163:5001
Press CTRL+C to quit
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 586-429-204
127.0.0.1 - - [22/Mar/2023 13:27:11] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [22/Mar/2023 13:27:12] "GET /mars HTTP/1.1" 200 -
127.0.0.1 - - [22/Mar/2023 13:27:13] "GET /favicon.ico HTTP/1.1" 404 -
 * Detected change in '/Users/suebe/Desktop/Sparta Coding/projects/02.mars/app.py', reloading
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 586-429-204
 * Detected change in '/Users/suebe/Desktop/Sparta Coding/projects/02.mars/app.py', reloading
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 586-429-204
127.0.0.1 - - [22/Mar/2023 13:35:43] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [22/Mar/2023 13:35:43] "GET /mars HTTP/1.1" 200 -
127.0.0.1 - - [22/Mar/2023 13:35:58] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [22/Mar/2023 13:35:58] "GET /mars HTTP/1.1" 200 -
샘플데이터
127.0.0.1 - - [22/Mar/2023 13:36:34] "POST /mars HTTP/1.1" 200 -
 * Detected change in '/Users/suebe/Desktop/Sparta Coding/projects/02.mars/app.py', reloading
 * Restarting with stat
Traceback (most recent call last):
  File "/Users/suebe/Desktop/Sparta Coding/projects/02.mars/app.py", line 5, in <module>
    client = MongoClient('mongodb+srv://sparta:test@cluster0.qmtll2o.mongodb.net/?retryWrites=true&w=majority', tlsCAFile=ca)
NameError: name 'ca' is not defined
(venv) suebe@MacBook-Air 02.mars % pip install certifi
Collecting certifi
  Using cached certifi-2022.12.7-py3-none-any.whl (155 kB)
Installing collected packages: certifi
Successfully installed certifi-2022.12.7
(venv) suebe@MacBook-Air 02.mars % deactivate
suebe@MacBook-Air 02.mars % source venv/Scripts/activate
source: no such file or directory: venv/Scripts/activate
suebe@MacBook-Air 02.mars % pip install certifi
zsh: command not found: pip
suebe@MacBook-Air 02.mars % "/Users/suebe/Desktop/Sparta Coding/projects/
02.mars/venv/bin/python" "/Users/suebe/Desktop/Sparta Coding/projects/02.
mars/app.py"
Traceback (most recent call last):
  File "/Users/suebe/Desktop/Sparta Coding/projects/02.mars/app.py", line 5, in <module>
    client = MongoClient('mongodb+srv://sparta:test@cluster0.qmtll2o.mongodb.net/?retryWrites=true&w=majority', tlsCAFile=ca)
NameError: name 'ca' is not defined
suebe@MacBook-Air 02.mars % 


from flask import Flask, render_template, request, jsonify
app = Flask(__name__)


from pymongo import MongoClient
client = MongoClient('mongodb+srv://sparta:test@cluster0.qmtll2o.mongodb.net/?retryWrites=true&w=majority', tlsCAFile=ca)
import certifi
ca = certifi.where()
db = client.dbsparta


@app.route('/')
def home():
    return render_template('index.html')


@app.route("/mars", methods=["POST"])
def mars_post():
    name_receive = request.form['name_give']
    address_receive = request.form['address_give']
    size_receive = request.form['siz_give']
    
    doc = {
        'name':name_receive,
        'address':address_receive,
        'size':size_receive
    }
    db.mars.insert_one(doc)


    return jsonify({'msg':'저장완료!'})


@app.route("/mars", methods=["GET"])
def mars_get():
    return jsonify({'msg':'GET 연결 완료!'})


if __name__ == '__main__':
    app.run('0.0.0.0', port=5001, debug=True)
취소
 공유
취소
댓글 0
댓글 알림
나의얼굴