전체 글
-
[Flask]Session사용하기 : RuntimeError: The session is unavailable because no secret key was set. Set the secret_key on the application to something unique and secret.언어/Python 2023. 2. 14. 14:40
Flask에서 Session을 사용하려면 from flask import session app = Flask(__name__) app.secret_key = os.urandom(24) app.config['SESSION_TYPE'] = 'filesystem' secret key를 추가해줘야한다. secret key에 'secret key' 같은 값을 넣어도 상관없지만, 유니크하게 가져가려고 나는 urandom으로 가져왔다. session['세션키'] = '세션밸류' 사용변수 = session['세션키'] 세션에 담을 값을 보내주는 곳과 받아주는 곳에 모두 저렇게 적어주면 끝 ! 예시 #로그인 정보 Cloud SQL로 넘기기 @app.route("/saveSQL", methods=['POST']) def ..
-
Cloud Translation API : source 를 HTML이 아닌 Text로 인식시키기 (' 가 ' 로 번역될때)클라우드/GCP 2023. 2. 10. 16:20
비슷한 고민이 Stack overflow에 https://stackoverflow.com/questions/60623314/translation-by-google-cloud-translate-api-returns-html-escaped-text Translation by Google Cloud Translate API returns html escaped text In my application, I am trying to translate a few Spanish texts to English using the Google Cloud Translation API. I noticed that the texts that I am receiving after translation is HTML escaped..
-
윈도우 로컬환경에서 Google Cloud Platform API 사용하기 전 Credentials 인증정보 세팅클라우드/GCP 2023. 2. 10. 13:44
로컬에서 파이참으로 Google Cloud API를 사용하려니 아래와 같은 에러가 뜬다. google.auth.exceptions.DefaultCredentialsError: Could not automatically determine credentials. Please set GOOGLE_APPLICATION_CREDENTIALS or explicitly create credentials and re-run the application. For more information, please see https://cloud.google.com/docs/authentication/getting-started Credentials 설정을 하라는 소리다. 설치 https://cloud.google.com/sdk..
-
[Flask]ImportError: cannot import name 'safe_str_cmp' from 'werkzeug.security' (E:\Dev\spot_new\venv\lib\site-packages\werkzeug\security.py)에러카테고리 없음 2023. 2. 9. 11:20
ImportError: cannot import name 'safe_str_cmp' from 'werkzeug.security' (E:\Dev\spot_new\venv\lib\site-packages\werkzeug\security.py) 플라스크를 사용하는데, 위와같은 import error가 자꾸떴다. 하나 해결하면 다른 하나가 뜨고.. Flask에서 메인으로 사용되는 세가지를 지웠다 다시 설치하니 해결됐다. pip uninstall flask pip install flask pip uninstall jinja2 pip install jinja2 pip uninstall Werkzeug pip install Werkzeug 버전은 Flask==2.1.3 Werkzeug==2.0.3 Jinja2==3...
-
Firebase 데이터 입출력카테고리 없음 2023. 2. 8. 13:29
먼저 Firebase 프로젝트를 생성해준 뒤, serviceAccountKey를 발급받는다. 코드 import firebase_admin from firebase_admin import credentials from firebase_admin import db if __name__ == '__main__': # Firebase database 인증 및 앱 초기화 cred = credentials.Certificate("serviceAccountKey.json") #json파일 경로 적어주기. 나는 프로젝트와 동일한 경로라서 파일명만 적음 firebase_admin.initialize_app(cred, { 'databaseURL': 'https://motigo-49f24-default-rtdb.fireba..
-
AutoScaling vs Load Balancing카테고리 없음 2023. 2. 8. 11:03
오토 스케일링(Auto Scaling) 이란 서버에 부하가 발생할 때, 자동적으로 서버 수를 늘려 부하를 분산하는 방식입니다. Load Balancing 은 들어오는 요청을 여러 서버로 분산해 주는 역할입니다. AutoScaling : process of launching (scaling out) and terminating(scaling in) instances based on the traffic demand for your application. You create collections of EC2 instances, called Auto Scaling Group. Load Balancing automatically distributes incoming traffic accross multiple ..