일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 |
- 빅데이터
- dataStructure
- 빅데이터 지식
- Computer Organization
- Heap
- data scientist
- 데이터 엔지니어
- Data Analyst
- Restroom
- BST
- 화장실 지도
- priority queue
- exam
- data
- 빅데이터 커리어 가이드북
- Newyork
- 데이터 분석가
- Data Engineer
- HEAPS
- Computer Science
- Preparing for the Google Cloud Professional Data Engineer Exam
- algorithm
- Data Structure
- Linked List
- hash
- Algorithms
- 뉴욕 화장실
- Binary Tree
- binary search tree
- Study
- Today
- Total
Jaegool_'s log
웹개발 종합반 5주차 내용 [스파르타 코딩] <bucket-list(toDoList), deploy a web with AWS & FileZilla & 가비아> 본문
웹개발 종합반 5주차 내용 [스파르타 코딩] <bucket-list(toDoList), deploy a web with AWS & FileZilla & 가비아>
Jaegool 2022. 5. 31. 19:11https://teamsparta.notion.site/5-18b62b60cc7d4343a5917dc8b7121977
[스파르타코딩클럽] 웹개발 종합반 - 5주차
매 주차 강의자료 시작에 PDF파일을 올려두었어요!
teamsparta.notion.site
<< Bucket list >>
<app.py> - server
from flask import Flask, render_template, request, jsonify
app = Flask(__name__)
from pymongo import MongoClient
import certifi
ca = certifi.where()
client = MongoClient('mongodb+srv://test:sparta@cluster0.l0equ.mongodb.net/Cluster0?retryWrites=true&w=majority', tlsCAFile=ca)
db = client.dbsparta
@app.route('/')
def home():
return render_template('index.html')
@app.route("/bucket", methods=["POST"])
def bucket_post():
bucket_receive = request.form['bucket_give']
bucket_list = list(db.bucket.find({}, {'_id': False}))
count = len(bucket_list) + 1
doc = {
'num':count,
'bucket':bucket_receive,
'done':0
}
db.bucket.insert_one(doc)
return jsonify({'msg': '등록 완료!'})
@app.route("/bucket/done", methods=["POST"])
def bucket_done():
num_receive = request.form['num_give']
db.bucket.update_one({'num':int(num_receive)},{'$set':{'done':1}})
return jsonify({'msg': '버킷 완료!'})
@app.route("/bucket", methods=["GET"])
def bucket_get():
bucket_list = list(db.bucket.find({}, {'_id': False}))
return jsonify({'buckets': bucket_list})
if __name__ == '__main__':
app.run('0.0.0.0', port=5000, debug=True)
< index.html > - client
<!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>
<link href="https://fonts.googleapis.com/css2?family=Gowun+Dodum&display=swap" rel="stylesheet">
<title>인생 버킷리스트</title>
<style>
* {
font-family: 'Gowun Dodum', sans-serif;
}
.mypic {
width: 100%;
height: 200px;
background-image: linear-gradient(0deg, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url('https://images.unsplash.com/photo-1601024445121-e5b82f020549?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=1189&q=80');
background-position: center;
background-size: cover;
color: white;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.mypic > h1 {
font-size: 30px;
}
.mybox {
width: 95%;
max-width: 700px;
padding: 20px;
box-shadow: 0px 0px 10px 0px lightblue;
margin: 20px auto;
}
.mybucket {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
}
.mybucket > input {
width: 70%;
}
.mybox > li {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
margin-bottom: 10px;
min-height: 48px;
}
.mybox > li > h2 {
max-width: 75%;
font-size: 20px;
font-weight: 500;
margin-right: auto;
margin-bottom: 0px;
}
.mybox > li > h2.done {
text-decoration: line-through
}
</style>
<script>
$(document).ready(function () {
show_bucket();
});
function show_bucket() {
$.ajax({
type: "GET",
url: "/bucket",
data: {},
success: function (response) {
let rows = response['buckets']
for (let i = 0; i < rows.length; i++) {
let bucket = rows[i]['bucket']
let num = rows[i]['num']
let done = rows[i]['done']
let temp_html = ``
if (done == 0) {
temp_html = `<li>
<h2>✅ ${bucket}</h2>
<button onClick="done_bucket(${num})" type="button" class="btn btn-outline-primary">완료!
</button>
</li>`
} else {
temp_html = `<li>
<h2 class="done">✅ ${bucket}</h2>
</li>`
}
$('#bucket-list').append(temp_html)
}
}
});
}
function save_bucket() {
let bucket = $('#bucket').val()
$.ajax({
type: "POST",
url: "/bucket",
data: {bucket_give:bucket},
success: function (response) {
alert(response["msg"])
window.location.reload()
}
});
}
function done_bucket(num) {
$.ajax({
type: "POST",
url: "/bucket/done",
data: {num_give:num},
success: function (response) {
alert(response["msg"])
window.location.reload()
}
});
}
</script>
</head>
<body>
<div class="mypic">
<h1>나의 버킷리스트</h1>
</div>
<div class="mybox">
<div class="mybucket">
<input id="bucket" class="form-control" type="text" placeholder="이루고 싶은 것을 입력하세요">
<button onclick="save_bucket()" type="button" class="btn btn-outline-primary">기록하기</button>
</div>
</div>
<div class="mybox" id="bucket-list">
</div>
</body>
</html>
위에 버킷 리스트를 만들면서 사용한 유용한 DB 함수들
from pymongo import MongoClient
import certifi
ca = certifi.where()
client = MongoClient('mongodb+srv://test:sparta@cluster0.l0equ.mongodb.net/Cluster0?retryWrites=true&w=majority', tlsCAFile=ca)
db = client.dbsparta
# 저장 - 예시
doc = {'name':'bobby','age':21}
db.users.insert_one(doc)
# 한 개 찾기 - 예시
user = db.users.find_one({'name':'bobby'})
# 여러개 찾기 - 예시 ( _id 값은 제외하고 출력)
all_users = list(db.users.find({},{'_id':False}))
# 바꾸기 - 예시
db.users.update_one({'name':'bobby'},{'$set':{'age':19}})
# 지우기 - 예시
db.users.delete_one({'name':'bobby'})
< ssh 로그인 접속 시 퍼미션 문제 >
AWS에서 서버를 구매한 후 서버에 연결하던 중 문제가 발생.
GitHub - rangyu/TIL: 오늘 내가 배운 것 (Today I Learned)
오늘 내가 배운 것 (Today I Learned). Contribute to rangyu/TIL development by creating an account on GitHub.
github.com
(Sparta coding club Slack 즉문즉답에 올라와 있던 질문)
내 컴퓨터에서 linux로 ubuntu서버에 연결이 되지 않던 문제를 위 GitHub 검색을 통해 해결할 수 있었다.
< OG tag로 카카오톡으로 보낼 때 꾸미기 >
<meta property="og:title" content="코난 그레이(Conan Gray) 팬명록" />
<meta property="og:description" content="응원 한 마디 남기고 가세요" />
<meta property="og:image" content="https://www.somagnews.com/wp-content/uploads/2020/03/39-6-e1585327776334.jpg" />
< 웹 배포 순서 >
1. AWS 서버 구매하기
2. 서버 세팅하기
3. flask 서버를 실행해보기
4. AWS에서 포트 열어주기
5. 포트포워딩
6. nohup 설정하기
7. 도메인 구입/연결하기
<HW>
웹을 만들고 배포까지 한 사이클을 돌아보았다.
요금이 더 나올까봐 몇 주후에 종료할 예정인 나의 첫 웹주소이다.
<소감>
강의가 짧지만 선생님의 강의력이 대단해서 많이 배웠고 몰입해서 문제점을 해결하는 것에 기쁨을 느꼈다.
또, 작지만 여러 프로젝트를 경험해 볼 수 있었다는 것이 좋았다.
배운 것을 토대로 응용하여 생각나는 아이디어를 웹으로 구현할 수 있으면 좋겠다.
앞으로도 꾸준히 개발일지를 쓰면서 배워가며 스스로에게 부끄럽지 않아야지 ㅎㅎ
'Development Log > Web Development' 카테고리의 다른 글
nyrestroom app image (0) | 2024.03.28 |
---|---|
What is AJAX? (0) | 2023.08.06 |
웹개발 종합반 4주차 내용 [스파르타 코딩] <Flask, POST, GET> (0) | 2022.05.23 |
웹개발 종합반 3주차 내용 [스파르타 코딩] <Python, crawling, mongoDB> (0) | 2022.05.21 |
웹개발 종합반 2주차 내용 [스파르타 코딩] <jQuery, Ajax> (0) | 2022.05.09 |