본격적인 웹페이지 개발에 앞서 기획안을 작성하여 페이지의 목적, 타켓유저, 구현할 기능을 정의 했다.
💡 **기획안**웹페이지의 목적:
타겟 유저:
구현할 기능:
이후, 기획안을 가장 잘 표현할수 있는 웹디자인을 구글링하여 선정하고 필요한 기능들을 구현할수 있도록 코드를 수정하고 웹페이지의 뼈대를 구축했다.
💡 활용한 tools:[https://www.w3schools.com/w3css/4/w3.css](https://www.w3schools.com/w3css/4/w3.css)
스파르타 코딩의 웹종합개발 강의 과제들을 참고하여 필수 기능들을 구현했다
# 파이썬 참고한 숙제 코드
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.v0amks8.mongodb.net/?retryWrites=true&w=majority',tlsCAFile=ca)
db = client.dbsparta
@app.route('/')
def home():
return render_template('bucket.html')
@app.route("/bucket", methods=["POST"])
def save_bucket():
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': '저장 완료!'})
@app.route("/bucket/done", methods=["POST"])
def done_bucket():
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 show_bucket():
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)
//html, css, JS 참고한 숙제 코드
<!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) {
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)
}
}
});
}
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">
<li>
<h2>✅ 호주에서 스카이다이빙 하기</h2>
<button onclick="done_bucket(5)" type="button" class="btn btn-outline-primary">완료!</button>
</li>
<li>
<h2 class="done">✅ 호주에서 스카이다이빙 하기</h2>
</li>
<li>
<h2>✅ 호주에서 스카이다이빙 하기</h2>
<button type="button" class="btn btn-outline-primary">완료!</button>
</li>
</div>
</body>
</html>
완성코드
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.v0amks8.mongodb.net/?retryWrites=true&w=majority',tlsCAFile=ca)
db = client.dbsparta
@app.route('/')
def home():
return render_template('index.html')
@app.route("/nycBucket", methods=["POST"])
def save_bucket():
count = list(db.nycBucket.find({}, {'_id': False}))
num = len(count)+1
done = 0
category_receive = request.form['category_give']
bucketItem_receive = request.form['bucketItem_give']
links_receive = request.form['links_give']
memo_receive = request.form['memo_give']
doc = {
'num': num,
'done': done,
'category': category_receive,
'bucketItem': bucketItem_receive,
'links': links_receive,
'memo': memo_receive
}
db.nycBucket.insert_one(doc)
return jsonify({'msg': 'List Saved!'})
@app.route("/nycBucket/done", methods=["POST"])
def done_bucket():
num_receive = request.form['num_give']
db.nycBucket.update_one({'num': int(num_receive)}, {'$set': {'done': 1}})
return jsonify({'msg': 'completed!'})
@app.route("/nycBucket", methods=["GET"])
def show_bucket():
items_list = list(db.nycBucket.find({}, {'_id':False}))
return jsonify({'items': items_list })
if __name__ == '__main__':
app.run('0.0.0.0', port=5000, debug=True)
<!DOCTYPE html>
<html>
<head>
<title>Subin's NYC Bucket List and Travel Manager</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<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">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<style>
body {
font-family: "Times New Roman", Georgia, Serif;
}
h1, h2, h3, h4, h5, h6 {
font-family: "Playfair Display";
letter-spacing: 5px;
}
.header_image {
width: 100%;
height: 500px;
background-image: linear-gradient(0deg, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url('https://s.yimg.com/ny/api/res/1.2/OucfyjfjqKoqZ_mXwtPDTw--/YXBwaWQ9aGlnaGxhbmRlcjt3PTk2MDtoPTU0MDtjZj13ZWJw/https://s.yimg.com/uu/api/res/1.2/4cTCbzGMlV8IqExbyzpiVw--~B/aD0xMDgwO3c9MTkyMDthcHBpZD15dGFjaHlvbg--/https://media.zenfs.com/en/gobankingrates_644/c598b71abc0b5732623a999fde50a539');
background-position: center;
background-size: cover;
color: white;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.about-section {
width: 100%;
height: 800 px;
background-position: center;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
margin-top: 20 px;
margin-bottom: 20 px;
text-align: center;
}
.bucket-section {
background-position: center;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
}
.box-image {
width: 1000px;
height: 300px;
background-image: linear-gradient(0deg, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url('https://media.timeout.com/images/103547775/1372/772/image.jpg');
background-position: center;
background-size: cover;
color: white;
display: flex;
justify-content: center;
align-items: center;
}
.box-image > button {
width: 200px;
height: 50px;
background-color: transparent;
color: white;
border-radius: 50px;
border: 1px solid white;
margin-top: 10px;
}
.box-image > button:hover {
border: 2px solid white;
}
.mypost {
width: 95%;
max-width: 1000px;
margin: 20px auto 0px auto;
padding: 20px;
box-shadow: 0px 0px 3px 0px gray;
display: none;
}
.mybutton {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
margin-top: 20px;
}
.mybutton > button {
margin-right: 10px;
}
.mybox {
width: 95%;
max-width: 1000px;
padding: 20px;
box-shadow: 0px 0px 10px 0px grey;
margin: 20px auto 0px auto;
margin: 20px auto;
margin-top: 100px;
margin-bottom: 100px;
}
.done {
text-decoration:line-through
}
.travel-section {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
margin-top: 20px;
margin-bottom: 20px;
}
.currency {
margin-top: 20px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
}
.map-section {
margin-top: 20px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.contact-section {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
</style>
<script>
function open_box() {
$('#post-box').show()
}
function close_box() {
$('#post-box').hide()
}
$(document).ready(function () {
show_bucket();
$('#list-box').empty()
});
function show_bucket() {
$.ajax({
type: 'GET',
url: '/nycBucket',
data: {},
success: function (response) {
let rows = response['items']
for (let i = 0; i < rows.length; i++) {
let category = rows[i]['category']
let bucket_Item = rows[i]['bucketItem']
let links = rows[i]['links']
let memo = rows[i]['memo']
let num = rows[i]['num']
let done = rows[i]['done']
let temp_html = ``
if (done == 0) {
temp_html = `<tr>
<td> <buttontoken interpolation">${num})" type="button" class="btn btn-outline-secondary"> ✔ </button> </td>
<td>${category}</td>
<td>${bucket_Item}</td>
<td><a href="${links}"> ${links}</a></td>
<td>${memo}</td>
</tr>`
} else {
temp_html = `<tr>
<th scope="row" class="done"> completed </th>
<td class="done">${category}</td>
<td class="done">${bucket_Item}</td>
<td class="done"><a href="${links}">${links}</a></td>
<td class="done">${memo}</td>
</tr>`
}
$('#list-box').append(temp_html)
}
}
});
}
function save_bucket() {
let category = $('#category').val()
let bucketItem = $('#bucketItem').val()
let links = $('#links').val()
let memo = $('#memo').val()
$.ajax({
type: 'POST',
url: '/nycBucket',
data: {category_give:category, bucketItem_give:bucketItem, links_give:links, memo_give:memo},
success: function (response) {
alert(response['msg'])
window.location.reload()
}
});
}
function done_bucket(num){
$.ajax({
type: "POST",
url: "/nycBucket/done",
data: {num_give: num},
success: function (response) {
alert(response["msg"])
window.location.reload()
}
});
}
</script>
</head>
<body>
<!-- Navbar (sit on top) -->
<div class="w3-top">
<div class="w3-bar w3-white w3-padding w3-card" style="letter-spacing:4px;">
<a href="#home" class="w3-bar-item w3-button">Bucket List Tracker and Travel Manager</a>
<!-- Right-sided navbar links. Hide them on small screens -->
<div class="w3-right w3-hide-small">
<a href="#about" class="w3-bar-item w3-button">About</a>
<a href="#bucket list" class="w3-bar-item w3-button">Bucket List</a>
<a href="#manager" class="w3-bar-item w3-button">Travel Manager</a>
<a href="#contact" class="w3-bar-item w3-button">Contact</a>
</div>
</div>
</div>
<!-- Header -->
<header>
<div class="header_image" id="home">
<h1> Bucket List Tracker and Travel Manager</h1>
</div>
</header>
<!-- page content -->
<div class="page-content">
<!-- About Section -->
<div class="about-section" id="about">
<div class="w3-col m6 w3-padding-large" style="margin: 100px" >
<h1 class="w3-center">About </h1><br>
<h5 class="w3-center">Welcome to Subin's Web Development Project</h5><br>
<p class="w3-large"> The Bucket List Tracker and Travel Manager is a website created for a web development project using HTML, CSS, JS, and Python.</p>
<p class="w3-large w3-text-grey w3-hide-medium"> This website is targeted for users who are traveling abroad and provides two main functions. </p>
<p class="w3-large w3-text-grey w3-hide-medium"> 1) Bucket List: recording and keeping track of the travel bucket list.</p>
<p class="w3-large w3-text-grey w3-hide-medium"> 2) Travel Manager: useful widgets for traveling abroad.</p>
</div>
</div>
<hr>
<!-- Bucket List Section -->
<div class="bucket-section" id="bucket list">
<div class="w3-col l6 w3-padding-large" style="margin: 80px">
<h1 class="w3-center"> Bucket List </h1><br>
<h4 class="w3-center"> Create your bucket list and track completed items, Bon Voyage!</h4>
</div>
<div class="box-image" id="open_box" >
<button onclick="open_box()"> click to start</button>
</div>
</div>
<div class="mypost" id="post-box">
<div class="input-group mb-3">
<label class="input-group-text" for="inputGroupSelect01"> Bucket Category</label>
<select class="form-select" id="category">
<option selected>--choose--</option>
<option value="Food & Drinks">Food & Drinks</option>
<option value="Arts & Performances">Arts & Performances</option>
<option value="Tours">Tours</option>
<option value="Date Nights & Weekends">Date Nights & Weekends</option>
<option value="Hangout with friends">Hangout with friends</option>
<option value="Shopping">Shopping</option>
</select>
</div>
<div class="form-floating mb-3">
<input type="email" class="form-control" id="bucketItem" placeholder="write here">
<label for="floatingInput">Bucket Litst Item</label>
</div>
<div class="form-floating mb-3">
<input type="email" class="form-control" id="links" placeholder="URL">
<label for="floatingInput">Links</label>
</div>
<div class="form-floating">
<textarea class="form-control" placeholder="Leave a comment here" id="memo"
style="height: 100px"></textarea>
<label for="floatingTextarea2">Memo</label>
</div>
<div class="mybutton">
<div class="d-grid gap-2 d-md-block">
<button type="button" onclick="save_bucket()" class="btn btn-dark">Submit</button>
<button type="button" onclick="close_box()" class="btn btn-outline-dark">Close</button>
</div>
</div>
</div>
<div class="mybox" id="bucket-box">
<h2 class="w3-center"> Fall 2022 NYC Bucket List</h2>
<table class="table">
<thead>
<tr>
<th scope="col"> Complete </th>
<th scope="col">Category</th>
<th scope="col">Bucket List Item</th>
<th scope="col">Links</th>
<th scope="col">Memo</th>
</tr>
</thead>
<tbody id="list-box">
<tr>
<td> <button onclick="done_bucket(1)" type="button" class="btn btn-outline-secondary"> ✔ </button> </td>
<td class="done"> </td>
<td >
<a href=""> </a></td>
<td > </td>
<td > </td>
</tr>
</tbody>
</table>
</div>
</div>
<hr>
<!-- Travel Manager Section -->
<div class="travel-section" id="manager">
<h1 >Travel Manager</h1><br>
<p>Travel Manager section provides useful widgets that help the users to be up-to-date about the weather and currency of the country they are visiting. </p>
<p>This section also allow the users to access their Google Calender and a Map to manage their schedules and document places visited or need to be visited .</p>
<div class="widget-section" id="widget" >
<h3 class="w3-center">Weather Widget</h3><br>
<div class="temperature" style="margin: 80px">
<div id="openweathermap-widget-15"></div>
<script>window.myWidgetParam ? window.myWidgetParam : window.myWidgetParam = [];
window.myWidgetParam.push({
id: 15,
cityid: '5128581',
appid: '17ed6b98c8736346ea39457af086bcc1',
units: 'metric',
containerid: 'openweathermap-widget-15',
});
(function () {
var script = document.createElement('script');
script.async = true;
script.charset = "utf-8";
script.src = "//openweathermap.org/themes/openweathermap/assets/vendor/owm/js/weather-widget-generator.js";
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(script, s);
})();</script>
</div>
<div class="currency" style="margin: 80px">
<h3 class="w3-center">Currency Widget</h3><br>
<!-- EXCHANGERATES.ORG.UK EXCHANGE RATE CONVERTER START -->
<script type="text/javascript">
var dcf = 'USD';
var dct = 'KRW';
var mc = '2D6AB4';
var mbg = 'FFFFFF';
var f = 'arial';
var fs = '11';
var fc = '000000';
var tf = 'arial';
var ts = '14';
var tc = 'FFFFFF';
var tz = '-8';
</script>
<script type="text/javascript" src="https://www.currency.me.uk/remote/ER-ERC-1.php"></script>
<small>Source: <a rel="nofollow" href="//www.exchangerates.org.uk" target="_new">ExchangeRates.org.uk</a></small>
<!-- EXCHANGERATES.ORG.UK EXCHANGE RATE CONVERTER END -->
</div>
</div>
<div class="calendar-section" id="calendar" style="margin: 80px">
<h3 class="w3-center">Manage your Calendar</h3><br>
<iframe src="https://calendar.google.com/calendar/embed?src=dc6d126b12a1d91eb23f694d761023728e9c88945bf65aaecc998d517967bfe4%40group.calendar.google.com&ctz=America%2FNew_York"
style="border: 0" width="1000" height="600" frameborder="0" scrolling="no"></iframe>
</div>
<div class="map-section" style="margin: 80px">
<h3 class="w3-center"> Keep Track of your Saved and Visited Places</h3><br>
<iframe src="https://www.google.com/maps/d/u/0/embed?mid=1kw75SfFElWu2cVMZyvU8uKxyOLnU5hQ&ehbc=2E312F"
width="1000" height="600"></iframe>
</div>
</div>
</div>
<hr>
<!-- Contact Section -->
<div class="contact-section" id="contact">
<h1>Contact</h1><br>
<p>If you liked my project and would like to check out my other works or want to discuss for projects or offer please contact me</p>
<p>email: baeksbs3@gmail.com</p>
</div>
<!-- End page content -->
</div>
<!-- Footer -->
<footer class="w3-center w3-light-grey w3-padding-32">
<p>Subin Baek 2022</p>
</footer>
</body>
</html>