목록Language/Python (16)
에라모르겠다(‘◇’)?

일단 가장 중요한 https://channels.readthedocs.io/en/stable/tutorial/part_1.html Tutorial Part 1: Basic Setup — Channels 4.0.0 documentation So far we’ve just created a regular Django app; we haven’t used the Channels library at all. Now it’s time to integrate Channels. Let’s start by creating a routing configuration for Channels. A Channels routing configuration is an ASGI application channels.readthed..

python에서 인터프리터 설정이 현재 가상환경의 python으로 되어있지 않은 경우엔 모듈을 설치한 경우에도 저런 빨간 줄과 함께 Unresolved reference 'django' 이런 메시지가 뜸 ㅎ - File -> Settings - Project Interpreter 접속 - Add Interpreter 눌러서 python 경로 수정해줌 지금보니 삭제한 가상환경 경로로 설정되어있음 - 그럼 개 빡치는 빨간줄 사라짐!

-- cmd pip install django-crontab -- setting.py INSTALLED_APPS = [ # ... 'django_crontab', ] CRONJOBS = [ ('0 * * * *', 'myapp.tasks.send_email'), ] 예시 작업 -- view.py from django.core.mail import send_mail def send_email(): subject = 'Test Email' message = 'This is a test email' from_email = 'sender@example.com' recipient_list = ['recipient@example.com'] send_mail(subject, message, from_email, re..

- ex) 10개의 json 데이터 ==> json_test.txt 파일로 저장 [ { "fruit": "apple", "flavor": "sweet", "color": "red" }, { "fruit": "banana", "flavor": "sweet", "color": "yellow" }, { "fruit": "orange", "flavor": "citrus", "color": "orange" }, { "fruit": "kiwi", "flavor": "tart", "color": "brown" }, { "fruit": "grape", "flavor": "sweet", "color": "purple" }, { "fruit": "mango", "flavor": "sweet", "color": "yello..

1. microseconds -> date 변환 from datetime import datetime def microseconds_to_date(request): microseconds = 1683114594400000 seconds, microseconds = divmod(microseconds, 1000000) dt = datetime.fromtimestamp(seconds) date_time = dt.strftime('%Y-%m-%d %H:%M:%S') print(date_time) return date_time - postman으로 response 값 확인 2. date -> microseconds 변환 from datetime import datetime def date_to_microseco..

업무에 쓸까 하고 짜봤던 코드였는데 전혀 다른 방식으로 진행하게 되어서 블로그에 올려야겠당🤫 {"timestamp" : "timestamp_value", "value" : "value" } json 모양을 가진 string 형태로 되어있는 데이터를 실행시간.json 파일로 변환하여 저장 후 데이터의 마지막 timestamp 시점을 이용하여 추가되는 timestamp 데이터부터 새로운 .json 파일로 저장하는 코드 [ 해당 데이터는 예시임 ] - test.txt 파일 - test2.txt 파일 from django.shortcuts import render from rest_framework.decorators import api_view from rest_framework.response import ..

RSA 암호화란🤮 ? RSA 암호는 공개키 암호 시스템의 하나로 ,암호화 뿐만 아니라 전자서명이 가능한 최초의 알고리즘 - RSA는 두 개의 키를 사용한다. RSA는 암호화와 복호화를 위한 두 개의 서로 다른 키를 사용. 하나는 공개키(Public Key)이고, 다른 하나는 개인키(Private Key) - 일반적으로 많은 공개키 알고리즘의 공개키(public key)는 모두에게 알려져 있으며 메시지를 암호화(encrypt)하는데 쓰이며(누구나 이를 이용하여 암호화 가능), 암호화된 메시지는 개인키(private key)를 가진 자만이 복호화(decrypt)하여 열어볼 수 있다. - 공개키 알고리즘은 누구나 어떤 메시지를 암호화할 수 있지만, 그것을 해독하여 열람할 수 있는 사람은 개인키를 지닌 단 한 ..

vscode를 사용하여 장고 프로젝트 초기 설정하는 방법 맨날 만들때마다 헷갈려서 적는거 아님..암튼 아님... 이제 좀 외우자..^^ 1. 가상환경 생성 python -m venv dev(가상환경 이름) 2. 가상환경 실행 1. cd 폴더명 -> cd Scripts -> activate 2. 폴더명/Scripts/activate 앞에 (dev)가 붙으면 가상환경 실행됨 종료는 deactivate 3. django 설치 pip install django(==4.1.7) 나는 4.1.7 버전으로 지정해서 설치함 ! 4. config 파일 설정 django-admin startproject config . config 라는 이름대신에 다른 이름으로 생성해도 됨 근데 config가 젤 나은듯 config라는 ..