티스토리 뷰


아직 시험판 이라고는 하지만 사용할 수 있다는 사실에 감격했습니다.

Experimental!

The Python 2.7 runtime is an experimental, innovative, and rapidly changing new feature for App Engine. Unfortunately, being on the bleeding edge means that we may make backwards-incompatible changes. We will inform the community once the Python 2.7 runtime is no longer experimental.


사실 제가 Python을 처음 접한게 3.x 버전이라 Google App Engine은 2.5만 지원했어서 사용하기가 좀 그랬었는데

이번에 2.7 지원 소식을 접하고 나서 본격적으로 사용을 좀 해볼까 합니다. ( 그동안은 구경만 했었던... )

우선 오늘은 누구나 처음 시작할때 하게되는 Hello, World!예제를 따라해 볼까 합니다.

가장 먼저 해야 할 일은 개발 환경을 구축하는 것이겠죠?
 

간단하네요... 그냥 하란대로만 하면...

혹시나 아직 App Engine 계정이 없으신 분들은 https://appengine.google.com/ 에 가입을 하시고 테스트용

Application을 하나 생성해 놓으시기 바랍니다. 그럼 이제 모든 준비가 완료됩니다.

우선 코드를 한번 볼까요?

Inside the helloworld directory, create a file named helloworld.py, and give it the following contents:

import webapp2

class MainPage(webapp2.RequestHandler):
   
def get(self):
       
self.response.headers['Content-Type'] = 'text/plain'
       
self.response.out.write('Hello, webapp2 World!')

app
= webapp2.WSGIApplication([('/', MainPage)],
                              debug
=True)



소스코드와는 별개로 설정파일도 생성해 주어야 합니다. application: 에는 helloworld대신 테스트용으로 생성한

application identifier를 입력하도록 합니다. 

Inside the helloworld directory, create a file named app.yaml with the following contents:

application: helloworld
version
: 1
runtime
: python27
api_version
: 1
threadsafe
: true

handlers
:
- url: /.*
  script
: helloworld.app


요렇게 2개의 파일을 만들었으면 이제 Deploy하기면 하면 완성이 됩니다.

설치한 Google App Engine Launcher를 실행하고 File -> Add Exisiting Application 을 눌러 위 파일을 생성해놓은

폴더를 지정해 줍니다. 목록에 해당 Application이 나타나면 선택Deploy 버튼을 눌러주면 로그인 창이 뜨는데,

여기에 내 Google App Engine 계정으로 로그인 하게되면 자동으로 Deploy가 되게 됩니다.

http://1.ApplicationIdentifier.appspot.com/

이제 내 Application 주소로 접속을 하게 되면 
 

Hello, webapp2 World!

 
다음과 같이 출력되었다면 정상적으로 Python 2.7로 첫 Google App Engine을 작성하신겁니다.

축하드려요 ^^/

앞으로도 하나씩 함께 배워나가 보도록 하겠습니다. 

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함