커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
4주차 스파르타피디아를 만들고 localhost:5000에 들어가면 오류가 나오네요
undefined주차
북마크
김*빈
댓글
38
추천
0
조회수
21
조회수
21
답변 완료

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

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


스파르타피디아에서 삭제버튼만들다가 계속 에러가 나서 다 삭제하고 새코드로 다 복붙했는데도 계속 오류가 나오네요



스파르타 즉문즉답




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:5000

 * Running on http://115.23.105.151:5000

Press CTRL+C to quit

 * Restarting with stat

 * Debugger is active!

 * Debugger PIN: 137-881-975

127.0.0.1 - - [08/Feb/2023 08:49:48] "GET / HTTP/1.1" 200 -

127.0.0.1 - - [08/Feb/2023 08:49:48] "GET /Jquery/prettify.js HTTP/1.1" 404 -

127.0.0.1 - - [08/Feb/2023 08:49:48] "GET /movie HTTP/1.1" 200 -

이건 파이참에서 뜨는 에러고


스파르타 즉문즉답


위에꺼는 로컬호스트5000들어가자마자 뜨는 오류고

아래꺼는 영화 기록할때뜨는 오류입니다.

mongodb 주소도 제대로 썼는데도 계속 문제가 발생하네요ㅜㅜ

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

from pymongo import MongoClient
client = MongoClient('mongodb+srv://ekqls6812:ekqls1251@cluster0.k35lvil.mongodb.net/?retryWrites=true&w=majority')
db = client.dbsparta

import requests
from bs4 import BeautifulSoup

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

@app.route("/movie", methods=["POST"])
def movie_post():
    url_receive = request.form['url_give']
    star_receive = request.form['star_give']
    comment_receive = request.form['comment_give']

    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36'}
    data = requests.get(url_receive, headers=headers)

    soup = BeautifulSoup(data.text, 'html.parser')

    og_image = soup.select_one('meta[property="og:image"]')
    og_title = soup.select_one('meta[property="og:title"]')
    og_description = soup.select_one('meta[property="og:description"]')

    image = og_image['content']
    title = og_title['content']
    description = og_description['content']

    doc = {
        'image':image,
        'title':title,
        'desc':description,
        'star':star_receive,
        'comment':comment_receive
    }

    db.movies.insert_one(doc)

    return jsonify({'msg':'POST 연결 완료!'})

@app.route("/movie", methods=["GET"])
def movie_get():
    movies_list = list(db.movies.find({},{'_id':False}))
    return jsonify({'movies':movies_list})

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