커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
5-11 팬명록 이미지 변경이 안됩니다
undefined주차
북마크
유*
댓글
9
추천
0
조회수
14
조회수
14
답변 완료

https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-15/311186727_1337085377098186_6960116428390923743_n.jpg?stp=dst-jpg_e35&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_cat=110&_nc_ohc=PjmtDHkvZ5wAX8kGZ63&edm=ALQROFkBAAAA&ccb=7-5&ig_cache_key=Mjk0NjQwMzcxMDA1NDE3NzcwNA%3D%3D.2-ccb7-5&oh=00_AfADP125MK_REt7fFcGu4p5bWiA1nhQJmedxlNcCWElJOA&oe=63D7F65C&_nc_sid=30a2ef


해당 이미지를 넣고 싶어 튜터님 따라 해봤으나 흰 배경만 나오네요

이미지의 링크 문제인가 싶어서 다른 이미지로도 해봤는데 계속 흰 배경으로 나와요ㅜㅜ 문제가 뭘까요



스파르타 즉문즉답





작성한 코드 및 에러 메세지

app.py

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


from pymongo import MongoClient
import certifi 
ca = certifi.where()
client = MongoClient('mongodb://sparta:test@ac-wjgmkb0-shard-00-00.cwcyaz3.mongodb.net:27017,ac-wjgmkb0-shard-00-01.cwcyaz3.mongodb.net:27017,ac-wjgmkb0-shard-00-02.cwcyaz3.mongodb.net:27017/?ssl=true&replicaSet=atlas-51s5pf-shard-0&authSource=admin&retryWrites=true&w=majority', tlsCAFile=ca) 
db = client.dbsparta 


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


@app.route("/guestbook", methods=["POST"])
def guestbook_post():
    name_receive = request.form['name_give']
    comment_receive = request.form['comment_give']


    doc = {
        'name':name_receive,
        'comment':comment_receive
        }
    db.fan.insert_one(doc)


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


@app.route("/guestbook", methods=["GET"])
def guestbook_get():
    all_comments = list(db.fan.find({},{'_id':False}))
    return jsonify({'result': all_comments})


if __name__ == '__main__':
   app.run('0.0.0.0', port=5001, debug=True)


index.html

(위에 사진이 아닌 조금더 짧은 링크의 사진을 넣은 코드입니다!)

<!DOCTYPE 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 href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous" />
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"
        integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM"
        crossorigin="anonymous"></script>


    <title>초미니홈피 - 팬명록</title>


    <meta property="og:title" content="LAUV 팬명록" />
    <meta property="og:description" content="아티스트에게 응원 한마디" />
    <meta property="og:image" content="http://image.newsis.com/2022/10/07/NISI20221007_0001102487_web.jpg" />


    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+KR:wght@200;300;400;500;600;700;900&display=swap"
        rel="stylesheet" />
    <style>
        * {
            font-family: "Noto Serif KR", serif;
        }


        .mypic {
            width: 100%;
            height: 300px;


            background-image: linear-gradient(0deg,
                    rgba(0, 0, 0, 0.5),
                    rgba(0, 0, 0, 0.5)),h
                url("http://image.newsis.com/2022/10/07/NISI20221007_0001102487_web.jpg");
            background-position: center 30%;
            background-size: cover;


            color: white;


            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
        }


        .mypost {
            width: 95%;
            max-width: 500px;
            margin: 20px auto 20px auto;


            box-shadow: 0px 0px 3px 0px black;
            padding: 20px;
        }


        .mypost>button {
            margin-top: 15px;
        }


        .mycards {
            width: 95%;
            max-width: 500px;
            margin: auto;
        }


        .mycards>.card {
            margin-top: 10px;
            margin-bottom: 10px;
        }
    </style>
    <script>
        $(document).ready(function () {
            set_temp();
            show_comment();
        });
        function set_temp() {
            fetch("http://spartacodingclub.shop/sparta_api/weather/seoul").then((res) => res.json()).then((data) => {
                let number = data['temp']
                $('#temp').text(number)
            });
        }
        function save_comment() {
            let name = $('#name').val()
            let comment = $('#comment').val()


            let formData = new FormData();
            formData.append("name_give", name);
            formData.append("comment_give", comment);


            fetch('/guestbook', { method: "POST", body: formData, }).then((res) => res.json()).then((data) => {
                alert(data["msg"]);
                window.location.reload()
            });
        }
        function show_comment() {
            fetch('/guestbook').then((res) => res.json()).then((data) => {
                let rows = data['result']
                $('#comment-list').empty()
                rows.forEach((a) => {
                    let name = a['name']
                    let comment = a['comment']


                    let temp_html = `<div class="card">
                                        <div class="card-body">
                                            <blockquote class="blockquote mb-0">
                                                <p>${comment}</p>
                                                <footer class="blockquote-footer">${name}</footer>
                                            </blockquote>
                                        </div>
                                    </div>`
                    $('#comment-list').append(temp_html)
                })
            })
        }
    </script>
</head>


<body>
    <div class="mypic">
        <h1>LAUV 팬명록</h1>
        <p>현재기온: <span id="temp">36</span></p>
    </div>
    <div class="mypost">
        <div class="form-floating mb-3">
            <input type="text" class="form-control" id="name" placeholder="url" />
            <label for="floatingInput">닉네임</label>
        </div>
        <div class="form-floating">
            <textarea class="form-control" placeholder="Leave a comment here" id="comment"
                style="height: 100px"></textarea>
            <label for="floatingTextarea2">응원댓글</label>
        </div>
        <button onclick="save_comment()" type="button" class="btn btn-dark">
            댓글 남기기
        </button>
    </div>
    <div class="mycards" id="comment-list">
        <div class="card">
            <div class="card-body">
                <blockquote class="blockquote mb-0">
                    <p>새로운 앨범 너무 멋져요!</p>
                    <footer class="blockquote-footer">호빵맨</footer>
                </blockquote>
            </div>
        </div>
        <div class="card">
            <div class="card-body">
                <blockquote class="blockquote mb-0">
                    <p>새로운 앨범 너무 멋져요!</p>
                    <footer class="blockquote-footer">호빵맨</footer>
                </blockquote>
            </div>
        </div>
        <div class="card">
            <div class="card-body">
                <blockquote class="blockquote mb-0">
                    <p>새로운 앨범 너무 멋져요!</p>
                    <footer class="blockquote-footer">호빵맨</footer>
                </blockquote>
            </div>
        </div>
    </div>
</body>


</html>
취소
 공유
취소
댓글 0
댓글 알림
나의얼굴