본문 바로가기
728x90
반응형

Python7

Firebase authentication 적용하기 (python) 설정 1. firebase-admin 라이브러리 설치 pip install firebase-admin 2. 공개키 생성하기 --> json파일이 생성됨. 3. python 구조 from firebase_admin import credentials, auth # cred = credentials.Certificate("/경로/생성된 비공개키 파일명.json") cred = credentials.Certificate("/service-account-key.json") default_app = firebase_admin.initialize_app(cred) # USER 여부 try: user = auth.get_user('localId') print('성공했을 경우 user의 정보를 불러옴: {0}'.form.. 2020. 3. 19.
python flask - blueprint main.py from flask import Flask from test_api import test_api app = Flask(__name__) app.register_blueprint(test_api) @app.route('/') def main(): return "hello" test_api.py from flask import Blueprint test_api = Blueprint('test_api', __name__, url_prefix='/test') @test_api.route("/here") def test(): return "here" flask server 올린 후 request: localhost:5000/ response : hello request: localhost:5000/.. 2020. 3. 12.
aggregation - mongodb ( $group, $project) mongodb에서 aggregation이란? mysql의 subquery 같은 기능을 쓸 수 있는 기능 기본 형태 쿼리 db.collection_name.aggregate([ { "$group": { '_id': { "user_id": "$user_id", "user_name": "$user_name" } }, { "$project": { "id": '$_id.user_id', "name": '$_id.user_name', } }]) 결과 [ { "_id": { "user_id" : 1, "user_name": "Minho" }, "id" : 1, "name": "Minho" }, { "_id": { "user_id" : 2, "user_name": "Suji" }, "id" : 2, "name": "S.. 2020. 3. 9.
728x90