-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.py
More file actions
84 lines (64 loc) · 2.02 KB
/
app.py
File metadata and controls
84 lines (64 loc) · 2.02 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
from flask import Flask
from pymongo import MongoClient
from flask_restx import Api
from routes import auth
from routes import photo
from routes import album
from dotenv import load_dotenv
import os
from flask import render_template, send_from_directory
app = Flask(__name__)
load_dotenv()
mongo_uri = os.getenv('MONGODB_URI')
client = MongoClient(mongo_uri)
db = client['albumate']
authorizations = {
'Bearer Auth': {
'type': 'apiKey',
'in': 'header',
'name': 'Authorization',
'description': "JWT 토큰을 'Bearer {token}' 형식으로 입력하세요."
}
}
app.config['RESTX_MASK_SWAGGER'] = False # 필드 마스크 비활성화
api = Api(
app,
version='0.1',
title='Photo App API',
description='사진 공유 앱의 API 서버',
terms_url='/',
doc='/swagger/',
authorizations=authorizations,
security='Bearer Auth',
mask=False # 필드 마스크 비활성화
)
api.add_namespace(auth.auth_ns, path='/api/auth')
api.add_namespace(album.album_ns, path='/api/albums')
api.add_namespace(photo.photo_ns, path='/api/photos')
# @app.route('/')
# def home():
# return "환영합니다! API 문서는 /swagger/에서 확인하세요."
@app.route("/login")
def login():
return render_template("login.html")
@app.route("/signup")
def signup():
return render_template("signup.html")
@app.route("/home")
def home():
return render_template("home.html")
@app.route("/album/<album_id>")
def album_detail_page(album_id):
return render_template("album.html", album_id=album_id)
@app.route("/photo/<photo_id>")
def photo_detail_page(photo_id):
return render_template("photo.html", photo_id=photo_id)
@app.route("/invitations")
def invitations_page():
return render_template("invitations.html")
@app.route('/uploads/<path:filename>')
def uploaded_file(filename):
uploads_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), 'uploads'))
return send_from_directory(uploads_dir, filename)
if __name__ == '__main__':
app.run(debug=True)