Created
October 20, 2009 01:35
-
-
Save ribrdb/213906 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'appengine-rack' | |
| require 'appengine-rack/java' | |
| # TODO: Fill in your app id | |
| AppEngine::Rack.app.configure(:application => '', :version => '1') | |
| run JavaServlet.new('DubyApp') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import javax.servlet.http.HttpServlet | |
| import com.google.appengine.ext.duby.db.Model | |
| class Post < Model | |
| def initialize; end | |
| property title, String | |
| property body, Text | |
| end | |
| class DubyApp < HttpServlet | |
| def_edb(list, 'template.eduby.html') | |
| def doGet(request, response) | |
| returns :void | |
| @posts = Post.all.run | |
| response.getWriter.write(list) | |
| end | |
| def doPost(request, response) | |
| post = Post.new | |
| post.title = request.getParameter('title') | |
| post.body = Text.new(request.getParameter('body')) | |
| post.save | |
| doGet(request, response) | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <title>Posts</title> | |
| <body> | |
| <h1>All Posts:</h1> | |
| <% i = 0; while i < @posts.length %> | |
| <h2><%= @posts[i].title %></h2> | |
| <p><%= @posts[i].body.getValue %></p> | |
| <% i += 1;end %> | |
| <hr> | |
| <h1>New Post:</h1> | |
| <form method=post> | |
| Title: <input type=text name=title><br> | |
| Body: <textarea name=body></textarea><br> | |
| <input type=submit> | |
| </form> | |
| </body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment