Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Week10 2 #5

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md

This file was deleted.

Binary file added __pycache__/database.cpython-312.pyc
Binary file not shown.
Binary file added __pycache__/database.cpython-37.pyc
Binary file not shown.
1 change: 1 addition & 0 deletions app/crawl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#이 파일은 예시고, 이런 식으로 app 파일 밑에 python backend 코드 파일을 기능별로 추가하면 된다.
96 changes: 96 additions & 0 deletions application.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
from flask import Flask, render_template , request, url_for, request, redirect , flash, session
from database import DBhandler
import hashlib
import sys

app = Flask(__name__)
app.config["SECRET_KEY"]="helloosp"
DB = DBhandler()


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

@app.route('/mypage')
def mypage():
return render_template('mypage.html')
@app.route('/login')
def login():
return render_template('login.html')





@app.route("/product-add")
def productAdd():
return render_template('product_add.html')


@app.route("/add-product-post", methods=["POST"])
def registerproduct():
data = {
"product_description": request.form.get("product-description"),
"product_place": request.form.get("product-place"),
"product_number": request.form.get("product-number"),
"product_category": request.form.get("product-category"),
"start_date": request.form.get("start-date"),
"end_date": request.form.get("end-date")
}
DB.insert_item(data['product_category'], data)
return render_template("products_list.html", data=data)





@app.route("/product-detail")
def productDetail():
return render_template('product_detail.html')

@app.route("/products-list")
def productsList():
return render_template('products_list.html')

@app.route("/review-add")
def reviewAdd():
return render_template('review_add.html')

@app.route("/review-detail")
def reviewDetail():
return render_template('review_detail.html')

@app.route("/reviews-list")
def reviewList():
return render_template('reviews_list.html')

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

@app.route("/signup2", methods=["GET", "POST"])
def signup2():
if request.method == "POST":
return redirect(url_for('signup1'))
return render_template('signup2.html')



@app.route("/signup1_post", methods=['POST'])
def register_user():
data = request.form
pw = request.form['pw']
pw_hash = hashlib.sha256(pw.encode('utf-8')).hexdigest()

if DB.insert_user(data, pw_hash):
return render_template("signup2.html")
else:
flash("user id already exist!")
return render_template("signup1.html")




if __name__ == '__main__':
app.run('0.0.0.0', port=5000, debug=True)
10 changes: 10 additions & 0 deletions authentication/firebase_auth.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"apiKey": "AIzaSyAVqcnhvGdXBsFFGKIaLnbaj0uhKWc_j2Y",
"authDomain": "orang2e.firebaseapp.com",
"databaseURL": "https://orang2e-default-rtdb.firebaseio.com",
"projectId": "orang2e",
"storageBucket": "orang2e.appspot.com",
"messagingSenderId": "711343754986",
"appId": "1:711343754986:web:32775e00125e5ef9ca5193",
"measurementId": "G-60K28M0YGW"
}
47 changes: 47 additions & 0 deletions database.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import pyrebase
import json

class DBhandler:
def __init__(self):
with open('./authentication/firebase_auth.json') as f:
config = json.load(f)
firebase = pyrebase.initialize_app(config)
self.db = firebase.database()

def insert_item(self, name, data):
item_info = {
"product_description": data['product_description'],
"product_place": data['product_place'],
"product_number": data['product_number'],
"product_category": data['product_category'],
"start_date": data['start_date'],
"end_date": data['end_date'],
}
self.db.child("item").child(name).set(item_info)
print(data)
return True

def insert_user(self, data, pw):
user_info = {
"id": data['id'],
"pw": pw,
"name": data['name']
}
if self.user_duplicate_check(str(data['id'])):
self.db.child("user").push(user_info)
print(data)
return True
else:
return False

def user_duplicate_check(self, id_string):
users = self.db.child("user").get()
print("users###", users.val())
if str(users.val()) == "None": # first registration
return True
else:
for res in users.each():
value = res.val()
if value['id'] == id_string:
return False
return True
22 changes: 22 additions & 0 deletions static/css/footer.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.footer-container {
width: 100%;
height: 340px;
display: flex;
align-items: top;
justify-content: left;
position: absolute;
bottom: 0;
border-top: solid 1px black;
padding-top: 50px;
padding-left: 5%;
color: black; /* Or any other text color */
font-size: 14px; /* Adjust as necessary */
}

.footer-content {
display: flex;
flex-direction: row;
gap: 10px; /* Adjust the space between items */
}

/* Add additional styling for the text as needed */
79 changes: 79 additions & 0 deletions static/css/header.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
* {
padding: 0;
margin: 0;
border: none;
box-sizing: border-box;
}

.header {
display: flex;
width: 100%;
height: 173px;
position: relative;
flex-direction: column;
justify-content: space-between;
align-items: center;
padding: 1rem 2rem; /* 여백 */
}

#logo {
flex-grow: 1; /* 로고 이미지가 더 큰 공간을 차지하도록 함 */
display: flex;
position: absolute;
left: 5%;
}
.nav {
width: 100%;
height: 80px;
display: flex;
position: absolute;

left: 5%;
bottom: 0;
}

.nav a {
text-decoration: none;
color: black;
margin: 0 1rem; /* 링크 사이의 간격 */
font-family: "Pretendard-SemiBold", sans-serif;
font-size: 1rem; /* 글자 크기 */
}

#login-btn,
#reg-btn,
#wish-btn,
#mypage-btn {
padding: 0.5rem 1rem; /* 버튼 내부 여백 */
border-radius: 5px; /* 버튼 모서리 둥글기 */
font-family: "Pretendard-Bold", sans-serif;
font-size: 0.875rem; /* 글자 크기 */
text-decoration: none;
display: flex;
align-items: center;
justify-content: center;
}

#login-btn,
#reg-btn {
background-color: #f5f5f5; /* 배경색 */
color: #5bab93; /* 텍스트 색상 */
margin-right: 1rem; /* 오른쪽 여백 */
}

#wish-btn {
background-color: #fffcf0; /* 배경색 */
color: #5bab93; /* 텍스트 색상 */
}

#mypage-btn {
background-color: #f5f5f5; /* 배경색 */
color: #5bab93; /* 텍스트 색상 */
}

.btn-box {
display: flex;
flex-direction: row;
position: absolute;
right: 5%;
}
Loading