커뮤니티
포인트
로딩중
쿠폰
내 강의실
국비 신청 내역
수강권
증명서
숙제 피드백
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
502 Bad Gateway
웹트랙 Lv.1 모바일 반응형 웹 v0
2주차
북마크
신*추
댓글
5
추천
0
조회수
17
조회수
17
답변 완료

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

AWS에서 502 Bad Gateway 가 떠요

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

1차 강의 따라가면서 시도

2차 AWS 다른 아이디로 가입해서 시도

3차 myweb 종료하고 다시 열고 강의에서 제공해 준 코드로 시도


어떻게 해야 될까요???



스파르타 즉문즉답스파르타 즉문즉답


스파르타 즉문즉답


스파르타 즉문즉답



from pymongo import MongoClient
from bs4 import BeautifulSoup
import requests
from flask import Flask, render_template, request, jsonify
app = Flask(__name__)



client = MongoClient(
    "mongodb+srv://sparta:test@cluster0.vlkbct6.mongodb.net/?retryWrites=true&w=majority")
db = client.pirates_lv1



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



@app.route('/exhibit', methods=["POST"])
def post_exhibit():
    url_receive = request.form["url_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')


    title = soup.select_one('#container > div.wide-inner > section > h3').text
    period = soup.select_one(
        '#container > div.detial-cont-element.active > div > dl:nth-child(1) > dd').text.strip()
    tags = soup.select_one(
        '#container > section.tag-element.poi > p').text.replace('\n', ' ')


    image = 'https://korean.visitseoul.net/' + \
        soup.select('.item')[1]['style'].split(
            '(')[1].replace(');', '').replace('\'', '')


    doc = {
        'title': title,
        'period': period,
        'tags': tags,
        'image': image,
        'url': url_receive
    }


    db.exhibition.insert_one(doc)


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



@app.route('/exhibit', methods=["GET"])
def get_exhibit():
    exhibitions = list(db.exhibition.find({}, {'_id': False}))
    return jsonify({'exhibitions': exhibitions})



@app.route('/now', methods=["GET"])
def get_now():
    url = 'https://korean.visitseoul.net/exhibition'
    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, headers=headers)
    soup = BeautifulSoup(data.text, 'html.parser')


    items = soup.select('.item > a')
    base = 'https://korean.visitseoul.net'


    docs = []
    for item in items:
        url = base+item['href']
        image = base + \
            item.select_one('.thumb')['style'].split('(')[1].replace(')', '')
        title = item.select_one('.title').text
        period = item.select_one('.small-text.text-dot-d').text.strip()
        doc = {
            'url': url,
            'image': image,
            'title': title,
            'period': period
        }
        docs.append(doc)


    return jsonify({'now': docs})



if __name__ == "__main__":
    app.run(debug=True, port=8080)





첨부파일 (1)

index.html
(7.607K)
취소
 공유
취소
댓글 0
댓글 알림
나의얼굴