가비아에서 내 웹사이트의 도메인 (주소)을 구매한다
AWS 에 가상의 컴퓨터를 구매해서 내 서버를 실행하고 종료한다
terminal을 열어서 SSH에 접속 하고 리눅스를 사용해서 AWS 컴퓨터를 실행한다
terminal 에서 내 ubuntu 서버 접속이 되지 않는다
subinbaek@Subins-MacBook-Air ~ % /Users/subinbaek/Downloads/sparta_web.pem
zsh: permission denied: /Users/subinbaek/Downloads/sparta_web.pem
subinbaek@Subins-MacBook-Air ~ % ssh i- /Users/subinbaek/Downloads/sparta_web.pem ubuntu@43.201.100.141
ssh: Could not resolve hostname i-: nodename nor servname provided, or not known
subinbaek@Subins-MacBook-Air ~ % sudo chmod /Users/subinbaek/Downloads/sparta_web.pem
usage: chmod [-fhv] [-R [-H | -L | -P]] [-a | +a | =a [i][# [ n]]] mode|entry file ...
chmod [-fhv] [-R [-H | -L | -P]] [-E | -C | -N | -i | -I] file ...
subinbaek@Subins-MacBook-Air ~ % ssh -i /Users/subinbaek/Downloads/sparta_web.pem ubuntu@43.201.100.141
The authenticity of host '43.201.100.141 (43.201.100.141)' can't be established.
ED25519 key fingerprint is SHA256:AAteYphf9z5iPvzPMQVkqBJeoHLSy9CguOn+SzvxLcE.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '43.201.100.141' (ED25519) to the list of known hosts.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for '/Users/subinbaek/Downloads/sparta_web.pem' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "/Users/subinbaek/Downloads/sparta_web.pem": bad permissions
https://bobbyhadz.com/blog/aws-ec2-warning-unprotected-private-key-file
EC2 설치하기
```python
# python3 -> python
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 10
# pip3 -> pip
sudo apt-get update
sudo apt-get install -y python3-pip
sudo update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1
# port forwarding
sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 5000
```
db 여러개 데이터 찾기 + 파이썬 len ()
@app.route("/bucket", methods=["POST"])
def bucket_post():
bucket_receive = request.form['bucket_give']
count = list(db.bucket.find({},{'_id':False}))
num = len(count)+1
done = 0
doc = {
'bucket': bucket_receive,
'num': num,
'done' done
}
db.bucket.insert_one(doc)
return jsonify({'msg': '저장 완료!'})
CSS (밑줄 치기 스타일 적용) , 조건문 활용하여 완료된 아이템 밑줄 그어주기
.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
}
h2 에 class=”done” 적용하기
function show_bucket(){
$('#bucket-list').empty()
$.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>
<buttontoken interpolation">${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)
}
}
});
}
done 0일 때와 아닐때로 조건을 구분하여 조건에 해당되는 코드를 실행한다
db 업데이트 해서 완료된 아이템 0 에서 1로 바꿔 주기 , int() 문자를 숫자로 바꿔주기
```python
@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': '버킷 완료!'})
```
- db 에 있는 num 을 불러와서 bucket_done 이라는 함수가 실행되면 db에 done 을 0 에서 1로 바꿔준다
- num 을 불러올때 db 안에서는 숫자가 아닌 문자로 저장되어있기 때문에 int() 라는 함수를 사용해서 숫자 1로 변환시켜 준다