구글 앱엔진 Java 에서 BlobStore 저장용 URL을 바로 받아 오기. 

public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException
{
    final String url = blobstoreService.createUploadUrl("/upload");

    final PrintWriter printWirter = res.getWriter();

    res.setContentType("text/plain");
    printWirter.write(url);

} 

 

기본 구조는 세 부분으로 구성되어 있다.

1. RequestHandler 클래스로 하나이상의 요청과 답변 처리

2. WSGIApplication 인스턴스로 URL을 통해 들어오는 요청을 처리

3. CGI Adapter로 WSGIApplication 메인루틴 실행

 

from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app


class MainPage(webapp.RequestHandler): #클래스 선언
  def get(self): #함수의 선언
    self.response.headers['Content-Type'] = 'text/plain'
    self.response.out.write('Hello, webapp World!')
    #여기가 함수의 종료점(파이썬은 띄어쓰기로 구분)
 
#'/' 로 들어 오는 요청을 MainPage 클래스와 연결
application = webapp.WSGIApplication(
                                     [('/', MainPage)],
                                     debug=True)

def main(): #메인루틴 실행 함수
  run_wsgi_app(application) #위에서 선언한 application을 실행함.

if __name__ == "__main__":
  main()
 
결과:
 

[관련글]
Hello, World! - Getting Started: Python - Google App Engine 
파이썬 구글 엡엔진 이클립스 개발환경 
Google App Engine 

 

 

pydev 업데이트 부터, 프로젝트 만들기, 디버깅, 업로드 까지 설명되어 있음.

>Getting Started: Python > Hello, World!

 

Hello, World!

Python App Engine applications communicate with the web server using the CGI standard. When the server receives a request for your application, it runs the application with the request data in environment variables and on the standard input stream (for POST data). To respond, the application writes the response to the standard output stream, including HTTP headers and content.

파이썬 엡엔진 어플은 CGI 표준을 사용하여 웹서버와 통신을 한다. 서버가 어플의 요청을 받을 때, 지정된 값의 요청 데이터와 데이터 표준 입력 스트림(POST data)으로 어플을 실행한다. 응답시, 어플은 HTTP 헤더와 내용을 포함시켜 표준 외부 스트림으로 응답을 보낸다.

 

Let's begin by implementing a tiny application that displays a short message.

간단한 메세지를 보여주는 작은 어플을 시작해 보자

 

Creating a Simple Request Handler 간단한 요청 핸들 만들기

Create a directory named helloworld. All files for this application reside in this directory.

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

helloworld 디렉토리를 만든다. 이 어플의 모든파일은 이 디렉토리에 존재한다. helloworld 디렉토리 안에 helloworld.py 파일을 만들고, 아래 내용을 넣는다.

 

print 'Content-Type: text/plain'

print ''

print 'Hello, world!'

 

This Python script responds to a request with an HTTP header that describes the content, a blank line, and the message Hello, world!

이 파이썬 스크립트는 공백과 Hello, world! 를 보여주는 HTTP 헤더를  응답한다.

 

Creating the Configuration File 환경파일 만들기

An App Engine application has a configuration file called app.yaml Among other things, this file describes which handler scripts should be used for which URLs.

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

응용 프로그램이 어느 파일을 사용해야 하는지 app.yaml 파일에 구성되어 있다. 그중에 이 파일은 URL을 사용에 따른 핸들러 스크립트를 포함하고 있다. (ㅡㅡ;)

helloworld 디렉토리 안에 app.yaml 파일을 만들고 아래 내용을 넣는다:

 

application: helloworld

version: 1

runtime: python

api_version: 1

handlers:- url: /.*

script: helloworld.py

 

From top to bottom, this configuration file says the following about this application:

처음 부터 끝까지, 이 구성 파일은 이 어플에 대해 아래에 이야기하고 있다.

 

  • The application identifier is helloworld. When you register your application with App Engine in the final step, you will select a unique identifier, and update this value. This value can be anything during development. For now, leave it set tohelloworld.
    어플 식별자는 helloworld. 마지막 단계에 엡엔진에 당신의 어플을 등록할 때, 유니크한 식별자로 업데이트 해야 한다. 이 값은 개발 중이기 때문에 지금은 helloworld로 설정해 놓았다.
  • This is version number 1 of this application's code. If you adjust this before uploading new versions of your application software, App Engine will retain previous versions, and let you roll back to a previous version using the administrative console.
    이 버젼의 어플 코드 번호는 1이다. 만약 전에 업로드한 당신의 어플의 새 버전을 조절하려고 하면, 앱엔진은 이전 버젼을 계속 유지할것이고, 관리 콘솔을 이용하면 이전 버전으로 돌릴 수 있다. (관리 콘솔은 http://appengine.google.com에 접속)

 

  • This code runs in the python runtime environment, version "1". Additional runtime environments and languages may be supported in the future.
    이 코드는 버젼 '1' 파이썬 런타임 환경에서 실행한다. 추가 런타임 환경과 언어는 차후 추가될 예정이다.
  • Every request to a URL whose path matches the regular expression /.* (all URLs) should be handled by the helloworld.py script.
    정규 표현 /.* (모든 URL)의 경로에 대한 모든 요청과 일치하는 URL은 helloworld.py 스크립트를 거쳐야 함을 명시.

 

The syntax of this file is YAML. For a complete list of configuration options, see the app.yaml reference.
이 파일의 문법은 YAML이다. 구헝옵션의 전체 목록을 보려면 the app.yaml reference을 보라

 

Testing the Application 어플 테스트 하기

With a handler script and configuration file mapping every URL to the handler, the application is complete. You can now test it with the web server included with the App Engine SDK.

Start the web server with the following command, giving it the path to the helloworld directory:

핸들러 스크립트와 설정파일은 핸들러로 모든 URL이 맵핑되고, 어플이 완성된다. 지금 앱엔진 SDK에 포함된 웹서버로 테스트 할수 있다.  주어진 helloworld 디렉토리의 경로를 아래의 명령어로 웹서버를 시작하자

 

google_appengine/dev_appserver.py helloworld/

 

The web server is now running, listening for requests on port 8080. Test the application by visiting the following URL in your web browser:

웹서버가 시작 되면, 포트8080 으로 요청을 대기중이다. 웹브라우저에서 아래 URL로 방문해서 어플을 테스트 하자.

 

 

For more information about running the development web server, including how to change which port it uses, see the Dev Web Server reference, or run the command with the option --help.

포트를 바꾸는 등의 개발 웹서버의 실행에 대한 더 많은 정보는, the Dev Web Server reference 를 참조 하거나, -help 옵션과 함께 명령어를 실행 해 보라.

 

Iterative Development 반복 개발

You can leave the web server running while you develop your application. The web server knows to watch for changes in your source files and reload them if necessary.

웹서버가 개발중인 동안에도 어플을  실행할수 있다. 웹 서버의 소스파일의 바뀐 내용을 보려면 새로고침 해야 한다.

 

Try it now: Leave the web server running, then edit helloworld.py to change Hello, world! to something else. Reload http://localhost:8080/ to see the change.

시도해 보자 : 서버를 실행 상태로 , helloworld.py 의 내용을 Hello, world! 처럼 바꿔 보자. http://localhost:8080 으로 새로고침 하면 바뀐걸 볼 수 있다.

 

To shut down the web server, make sure the terminal window is active, then press Control-C (or the appropriate "break" key for your console).

웹서버를 종료하려면, 터미널에서 Ctrl + C 를 입력 (또는 콘솔의 break 키를 입력)

 

You can leave the web server running for the rest of this tutorial. If you need to stop it, you can restart it again by running the command above.

 

Next...

You now have a complete App Engine application! You could deploy this simple greeting right now and share it with users worldwide. But before we deploy it, let's consider using a web application framework to make it easier to add features.

Continue to Using the webapp Framework.

앱엔진을 어플을 만들어 보았다. 간단한 배포로 웹세상에 공유할수 있다. 배포전에, 원하는 기능을 쉽게 추가 할수 있는 프레임 워크를 사용해 보자. 프레임워크 사용하기로..

.

>Getting Started: Python > The Development Enviroment

 

The Development Environment 개발 환경

You develop and upload Python applications for Google App Engine using the App Engine Python software development kit (SDK).

당신은 앱엔진 파이썬 소프트웨어 개발킷(SDK)을 사용한 GAE로 파이썬 어플을 개발하고 업로드한다.

 

The Python SDK includes a web server application that simulates the App Engine environment, including a local version of the datastore, Google Accounts, and the ability to fetch URLs and send email directly from your computer using the App Engine APIs. The Python SDK runs on any computer with Python 2.5, and versions are available for Windows, Mac OS X and Linux. (The Python SDK is not compatible with Python 3.)

파이썬 SDK는 로컬 데이터저장소, 구글 계정, 그리고 앱엔진 API들을 활용하여 당신의 컴퓨터로부터 URL를 가져오고 직접 이메일을 보내는 앱엔진 환경을 시뮬레이션한 웹서버를 포함하고 있다.  파이썬 SDK 파이썬 2.5가 가능한 윈도우, 맥, 리눅스라면 어떤 컴퓨터에서도 실행 할수 있다.(파이썬3과는 호환되지 않는다.)

 

If necessary, download and install Python 2.5 for your platform from the Python web site. Mac OS X 10.5 Leopard users already have Python 2.5 installed.

만약 필요하면, the Python web site로 부터 당신의 플렛폼에 맞는 파이썬2.5를 다운 받아 설치하라. 맥 OS X 10.5 레오파드 유저는 이미 파이썬2.5가 인스톨 되어 있다.

 

Download the App Engine SDK. Follow the instructions on the download page to install the SDK on your computer.

다운로드 the App Engine SDK. 컴퓨터에 설치하려면 다운로드 페이지의 설명을 따르면 된다.

 

For this tutorial, you will use two commands from the SDK:

이 설명서는 SDK에서 두가지 명령을 사용할 것이다.

  • dev_appserver.py, the development web server 개발서버 실행
    ex) dev_appserver.py [프로젝트폴더]
  • appcfg.py, for uploading your app to App Engine 어플을 앱엔진에 업로드
    ex) appcfg.py update [프로젝트폴더]    -> 앱엔진 가입되어 있는 구글계정 입력요구

 

For Windows users: the Windows installer puts these commands in the command path. After installation, you can run these commands from a command prompt.

윈도우즈 유저 : 윈도우 설치 프로그램이 시스템 path에 위의 명령어의 설치 경로을 추가한다. 설치후 명령어창에서 위의 명령으로 실행가능하다.

 

For Mac users: Google App Engine Launcher includes these commands with the application. You can put these commands in the command path by selecting "Make Symlinks..." from the "GoogleAppEngineLauncher" menu. Alternatively, you can use the Launcher to run the development web server and deploy your application instead of running the commands.(난 맥이 없음.. ^^; 곧 구해야 할텐데..)

 

If you are using the Zip archive version of the SDK, you will find these commands in the google_appengine directory.

만약 Zip 버젼 SDK를 사용한다면, google_appengine 디렉토리에서 명령어를 찾아함. (시스템 path에 추가하면 됨)

 

Next...

The local development environment lets you develop and test complete App Engine applications before showing them to the world. Let's write some code.

Continue to Hello, World!

로컬 개발 환경은 엡엔진 어플을 세계에 보여주기 전에 개발하고 테스트 할 수 있다. 몇가지 코드를 작성해 보자, Hello, World! 로 가기 ^^

.

>Getting Started: Python > Introduction

 

Introduction 서론

Welcome to Google App Engine! Creating an App Engine application is easy, and only takes a few minutes. And it's free to start: upload your app and share it with users right away, at no charge and with no commitment required.

Google App Engine(이하 GAE)에 온것을 환영한다. 앱엔진 어플리케이션(이하 어플) 만들기는 쉽고, 단지 몇분의 작업으로 가능하다. 그리고, 무료로 시작할수 있다.

 

Google App Engine applications can be written in either the Java or Python programming languages. This tutorial covers Python. If you're more likely to use Java to build your applications, see Getting Started: Java.

GAE 어플은 Java 또는 Python 프로그램언어로 개발 가능하다. 이 설명서는 파이썬용. 만약 자바를 원한다면 Getting Started: Java. 보기 바람.

 

In this tutorial, you will learn how to:

이 설명서에서 배울 것:

 

  • build an App Engine application using Python    파이썬으로 어플만들기
  • use the "webapp" web application framework    웹어플구조인 "webapp" 사용하기
  • use the App Engine datastore with the Python modeling API 
    파이썬 modeling API로 GAE 데이터저장소 사용하기
  • integrate an App Engine application with Google Accounts for user authentication
    유저인증을 위한 구글계정과 GAE 통합하기
  • use Django templates with your app   어플에 Djange 구조 사용하기
  • upload your app to App Engine   어플 업로드

 

By the end of the tutorial, you will have implemented a working application, a simple guest book that lets users post messages to a public message board.

설명서가 끝날무렵,  당신은 사용자가 메세지를 쓸수 있는 간단한 게시판을 구현할 것이다.

 

To get started developing Google App Engine applications, you download and set up the App Engine software development kit.

GAE 어플 개발 시작을 위해서는 GAE 개발킷을 다운로드 해야 한다.

 

Continue to The Development Environment.

 

.

개발준비중인 엡엔진의 원문을 번역하려한다. 의역과 오역이 난무 하더라도 너그러이 봐주시길.. 하다 보면 나은 결과물이 나올지도.. ^^;

 

Getting Started: Python

구글 앱엔진 시작하기 :  파이썬

This tutorial describes how to develop and deploy a simple Python project with Google App Engine. The example project, a guest book, demonstrates how to use the Python runtime environment, and how to use several App Engine services, including the datastore and the Google user service.

이 예제는 Google App Engine에서  간단한 파이썬 프로젝트를 어떻게 개발하고 배포 하는지 묘사하고 있다.  guestbook예제는 파이썬 런타임 환경에서 어떻게 운영하는지 보여주고 , 데이터스토어와 구글 유저 서비스 같은 몇몇 서비스를 사용법을 보여준다.

 

This tutorial has the following sections:

이 설명서는 아래 부분으로 구성되어 있다.

 

.

'AppEngine' 카테고리의 다른 글

Introduction - Getting Started: Python - Google App Engine  (0) 2009.08.17
Google App Engine  (0) 2009.08.17
구글 앱엔진 학습 - GWT예제  (0) 2009.06.29

~ Google App Engine

  • 시작하기
    • ~ GAE는 무엇인가?
      • 트래픽이 늘어나더라도 구글이 모두 관리 함, 어플리케이션 개발에만 신경쓰도록 해줌
      • 어플리케이션 환경
        • 샌드박스(모레상자)
        • 자바 런타임 환경
        • 파이썬 런타임 환경
        • 데이터저장
        • 구글 계정
        • 앱엔진 서비스
        • URL 가져오기
        • Mail
        • Memcache
        • 이미지 처리
        • 작업 스케줄과 작업 대기열
      • 개발 흐름
      • 할당과 한계
    • Java
      • ~ 서론
      • Java SDK 인스톨하기
      • 프로젝트 만들기
      • 유저서비스 사용하기
      • JSP 사용하기
      • JDO와 데이타 스토어 사용하기
      • Static 파일 사용하기
      • 어플리케이션 업로드
  • 추가링크

GAE(Google App Engine) 학습 하기

Google App Engine Java 시작하기 문서 의 내용만으로는 구조가 잘 이해가 안되던 상황에 Google Web Tookit - Getting Started 예제를 보게 되었다. 생각보다 쉽게 잘 되어 있다. ^^

 

Google Web Tookit - Getting Started 예제

 

예제 문서의 장점

제작 순서와 구조에 대한 설명이 짧은 영어 실력으로도 따라 하다 보면 숙지 할 수 있을 만큼 잘 만들어진 예제 같다. eclipse에서 plugin으로 작업가능하고 그냥 에디터로도 가능하도록 설명 되어있다.

 

제공하는 내용은 아래와 같다.

 

GWT에서 AJAX 어플리케이션 제작 프로세스

1. GWT 프로젝트 만들기

2. 어플리케이션 디자인하기

3. 유저인터페이스 만들기

4. 이벤트 제어

5. 클라이언트에서 코드 상관관계

6. 디버깅

7. 스타일 적용

8. 컴파일

 

따라 하다 보니 어느덧 구조가 이해가 되고 있다.. (금방 잊어 버리면 안 되는데…^^;)

'AppEngine' 카테고리의 다른 글

구글 엡엔진 시작하기 : 파이썬 버젼  (0) 2009.08.17
Google App Engine  (0) 2009.08.17
구글 AppEngine에서 이미지 파일 업로드  (0) 2009.06.25

AppEngine 에서 파일 업로드 테스트

App Engine 에서는 파일 쓰기가 아닌 데이타베이스에 저장되어야 한다.

최대 사이즈 1메가바이트 까지 업로드 됨

 

분석하고 싶은 것

http://vladysla-vtserman.appspot.com/ 와 같은 파일 업로드 만들기

 

참고 : gruops.google.com에 올라온 해당 토론

구글 그룹스 :

http://groups.google.com/group/google-appengine-java

 

QnA :

여러 형태의 데이터를 어떻게 처리 하나요?

내 애플 리케이션에 업로드 파일을 어떻게 처리 하나요?

http://code.google.com/intl/ko-KR/appengine/kb/java.html#fileforms

 

GWT (Google Web Toolket) 예제

http://gwt.google.com/samples/Showcase/Showcase.html#CwFileUpload

'AppEngine' 카테고리의 다른 글

구글 엡엔진 시작하기 : 파이썬 버젼  (0) 2009.08.17
Google App Engine  (0) 2009.08.17
구글 앱엔진 학습 - GWT예제  (0) 2009.06.29

+ Recent posts