The more I look at Flask the more I get a hard on.
because you have to write everything from scratch to do anything useful with it?
The more I look at Flask the more I get a hard on.
All this talk about smaller, micro type frameworks has me looking into something to build more restful apps with.
I took a look at a few across python, ruby, and php and came up with this short list:
1. Slim, MicroMVC, Laravel - PHP
2. Merb, Sinatra, Camping - Ruby
3. Flask, Bottle, CherryPy - Python
I am going to try to make a simple rest api out of each ( mainly to learn ruby and python more ) and see which one I end up liking.
because you have to write everything from scratch to do anything useful with it?
I know you be trolling but, no you don't. There are lots of useful plugins AND it gives you the ability to write anything from scratch or integrate something without getting in your way. That's the way it should be.
SQLAlchemy actually looks useful vs Djangos ORM (which I'm not very fond of).
I was able to get a small example app up in running in like an hour or two from 0 knowledge. Can't say I've had the same experience with Django.
so now you're using frameworks AND ORMs???
What strongly-argued-yet-incorrect programming opinion are you going to go back on next? My guess is using deployment automation instead of FTP.
I think the most important thing a new programmer can do is to build awesome things because that is very motivating. That's why I recommend starting with frameworks, as they speed up development and help you build awesome stuff.
As you progress, you can start peeling back the layers and learning how everything works. I don't program for fun, fun for me is building products and cool shit, and programming is what allows me to do that.
because you have to write everything from scratch to do anything useful with it?
narrowed it down to:
Slim for PHP
Sinatra for Ruby
Flask for Python ( although bottle looks really simple ).
narrowed it down to:
Slim for PHP
Sinatra for Ruby
Flask for Python ( although bottle looks really simple ).
Our initial file hierarchy
-- app/
+-- Gemfile
+-- Rakefile
+-- app.rb
+-- config.ru
require "./app"
run Sinatra::Application
source :rubygems
gem "sinatra"
gem "sqlite3"
gem "activerecord"
gem "sinatra-activerecord"
group :development do
gem "shotgun" # Development server that auto-reloads our environment
gem "tux" # Sinatra dev console
end
# Rakefile
require "./app"
require "sinatra/activerecord/rake"
require "sinatra"
require "sinatra/activerecord"
set :database, "sqlite3:///articles.db"
class Article < ActiveRecord::Base
end
get "/" do
@articles = Article.all
erb :index
end
__END__
@@ layout
<!DOCTYPE html>
<title>Gay Webmaster Forum</title>
<%= yield %>
@@ index
<h1>Articles</h1>
<ul>
<% @articles.each do |article| %>
<li><%= article.title %></li>
<% end %>
</ul>
$ bundle install
Gemfile locked
Let's see our rake tasks:
$ rake -T
rake db:migrate
rake db:rollback
rake db:create_migration NAME=some_name
Start the shotgun server:
$ shotgun
Listening on localhost:9393
$ rake db:create_migration NAME=create_articles
Generated file: db/migrate/201210201150_create_articles.rb
class CreateArticles < ActiveRecord::Migration
def change
create_table :articles do |t|
t.string :title
t.text :body
t.timestamps
end
end
end
$ rake db:migrate
Articles table created
$ tux
>> Article
Article(id: integer, title: string, body: text, created_at: datetime, updated_at: datetime)
>> 10.times { Article.create(title: "Testing", body: "Testing") }
>> Article.count
10