본문 바로가기
728x90
반응형

개발/python, python frameworks5

PyInstaller shell 없애기 개발 1. pyqt, pyinstaller를 이용해 프로그램을 만든 후 해당 명령어로 subprocess를 통해 입력한 repo git clone하는 프로그램 만듦 pyinstaller -y -w -F -i app.ico 파일이름.py 문제발생 subprocess 실행 시 shell이 계속 켜지는 문제 발생 문제 해결 해당 코드를 shell=False 부분을 shell=True 로 변경 고치기 전 p = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=False, encoding="utf8", cwd=working_dir, stdin=subprocess.DEVNULL) 고친 후 p = subprocess.run.. 2020. 4. 21.
python(flask)에서 DTO 활용하기(예제) python은 기본적으로 type이 strict하지 않다. 따라서 parameter나 argument에 사용하는 type이 무엇인지 알수가 없기 때문에 DTO를 쓰면 데이터의 흐름을 보기가 힘든 단점이 있다. 그러나 python은 3.5 ~ 3.8 을 거치며 최신 파이썬은 argument의 type을 보일 수 있게 되었다. (또한 아래와 같이 argument에 정의한 class를 사용 가능하다.) from flask import jsonify from flask_wtf import FlaskForm from wtforms import StringField app = Flask(__name__) class NumberExampleForm(FlaskForm): class Meta: csrf = False f.. 2020. 4. 3.
AES256/ base64 암호화 with python 1. install pycrytpodome pip install pycryptodome 2. python class import base64 from Crypto import Random from Crypto.Cipher import AES class AES256(): def __init__(self, key): self.bs = 128 self.key = key.encode('utf-8') self.key = AES256.str_to_bytes(key) @staticmethod def str_to_bytes(data): u_type = type(b''.decode('utf8')) if isinstance(data, u_type): return data.encode('utf8') return data d.. 2020. 3. 30.
카카오 로그인 (python에 붙이기) import requests import json host = 'kapi.kakao.com' admin_key = 'admin key' user_id = '유저 아이디' def getAllUsers(): headers = { 'Host': host, 'Authorization': f'KakaoAK {admin_key}', 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8' } res = requests.get(f'https://{host}/v1/user/ids', headers=headers) print(res.json()) def getUserInfo(): headers2 = { 'Host': host, 'Authorization': f.. 2020. 3. 23.
728x90