Created
May 16, 2012 09:55
-
-
Save pobo380/2709176 to your computer and use it in GitHub Desktop.
This file contains 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
# coding: utf-8 | |
require 'rubygems' | |
require 'sinatra' # c=>include, java,python=>import | |
require 'sequel' | |
Sequel::Model.plugin(:schema) | |
DB = Sequel.sqlite('database.sqlite3') | |
## create a table. | |
class Post < Sequel::Model | |
unless table_exists? | |
set_schema do | |
primary_key :id | |
string :text | |
end | |
create_table | |
end | |
end | |
Messages = [] | |
get "/" do | |
erb <<-EOS | |
<html> | |
<head> | |
<title>My BBS</title> | |
</head> | |
<body> | |
<h1>My BBS</h1> | |
<form action="/toukou" method="post"> | |
<div><input type="text", name="message"></div> | |
<div><input type="submit", value="submit"></div> | |
</form> | |
<div> | |
<% Messages.each do |msg| %> | |
<p> | |
Message: <%= msg %> | |
</p> | |
<% end %> | |
</div> | |
</body> | |
</html> | |
EOS | |
end | |
post '/toukou' do | |
Post.create(:text => params[:message]) | |
Post.all | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment