Wireframe

윈도 시스템에 Pyramid 설치하기

윈도 시스템에 Pyramid 설치하기

Pyramid란?

Pyramid는 파이썬기반의 경량 프레임워크이다. 자세한 설명은 생략한다. 링크를 참조하자. Pyramid

설치

준비물

Pyramid를 설치하려면 다음의 내용들이 필요하다.

설치 순서 (python 2.7/3.2)

  1. virtualenv를 설치한다. c:\> c:\python27\scripts\easy_install virtualenv
  2. 가상 환경을 만들어 준다 c:\> c:\python27\scripts\virtualenv --no-site-packages env
  3. 가상 환경 디렉토리로 이동 c:\> cd env
  4. 이 위치에서 Pyramid를 설치한다. c:\env\> c:\python27\script\easy_install pyramid

버전에 따른 차이는 pywin32의 버전만 동일하게 맞추면 된다. 또한 만약 여러 버전이 설치된 시스템에서는 각 버전에 맞게 따로 따로 가상환경을 만들고 설치한다.

Pyramid 예제 실행

가상환경에서의 파이썬 인터프리터는 c:\env\scripts 에 위치해 있다. Pyramid를 사용하는 파일을 작성한 후에는 c:\env\scripts\python 파일.py로 실행한다.
다음은 Pyramid 홈페이지에 나와있는 간략한 코드.

from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.response import Response
def hello_world(request):
    return Response('Hello %(name)s!' % request.matchdict)
if __name__ == '__main__':
    config = Configurator()
    config.add_route('hello', '/hello/{name}')
    config.add_view(hello_world, route_name='hello')
    app = config.make_wsgi_app()
    server = make_server('0.0.0.0', 8080, app)
    server.serve_forever()

실행시에는 c:\env\scripts\python sample.py로 실행한 후 웹 브라우저로 localhost:8080/hello/ 로 접속하면 낯익은 문구가 반겨줄 것이다.

Exit mobile version