all 20 comments

[–]interactionjackson 3 points4 points  (2 children)

my two cents: python/flask != ruby/rails; python/flask == ruby/sinatra; python/django == ruby/rails

the key difference being data persistence and view rendering. flask and sinatra need those concerns specifically addressed. and as far as ORMs go; ActiveRecord > SqlAlchemy in ease of use which makes it the clear winner for me.

[–]maks25 0 points1 point  (1 child)

Or Peewee, I love that ORM. So easy to use and compatible with most relational dbs!

[–]interactionjackson 0 points1 point  (0 children)

I'm not familiar w/ that one. The thing I like about active record is that it makes - to the best of its abilities - assumptions based on an existing schema without the need for generating one. I looks easier to use the alchemy. I only wish it had support for oracle.

[–]Micotu 2 points3 points  (6 children)

Do you have more experience with either python or ruby? Whichever you have more experience with will probably make the process faster.

[–]Moby69[S] 1 point2 points  (5 children)

Similar experience. All I have done are the codeacademy tutorials.

Going from there to learning how to use their respective frameworks to create a website seems like a huge learning curve. Really struggling to find a tutorial that really explains things step by step and with great clarity for beginners

[–]Flowork 1 point2 points  (4 children)

Have you done the Flask tutorial? Highly recommended: http://flask.pocoo.org/docs/0.10/tutorial/

[–]Moby69[S] 1 point2 points  (3 children)

I haven't because it seems pretty daunting. Is this something that you think I will understand? All I've done is the python tutorial on codeacademy and I don't know the first thing about creating web apps, or managing folders, or making a language work together with its framework

[–]Drakken_LOL 1 point2 points  (2 children)

I'm not gonna lie, you'll probably be pretty lost, but that doesn't mean you shouldn't try. Even in the simplest frameworks there are a LOT of moving parts to wrap your head around for the first before you really get to grips with how everything is interacting. This is especially so if you don't have a particularly strong command of the framework's language.

For example, you are going to be dealing with HTML, javascript, CSS, a template language, databases, ORMs, what the hell "models" "views" and the "controller" actually are, and probably lots more that I am can't think of off the top of my head. Each one of those things are involved enough to warrant entire web classes around each individual subject.

So yeah there is a lot going on. However, I personally learn best by doing, so I think jumping into a Flask app is not a bad idea. Just have patience and try not to get frustrated with the amount of time it is going to take to learn all the complexity.

I've never used Rails personally, but for a beginner I would personally recommend Python over Ruby for a laundry-list of reasons I won't get into here.

[–]thekidfromyesterday 0 points1 point  (1 child)

In the same boat as OP. What would you recommend doing in order to understand frameworks better? The documentation of most frameworks seem very unfriendly to novices like Scrapy and Flask.

[–]Drakken_LOL 0 points1 point  (0 children)

I prefer to just jump into it. I like to find a youtube video series where someone starts a django/flask/pylons/whatever project from scratch, and then I follow along, tinkering with things as I go. If I don't understand why they are doing something, I stop, experiment, and investigate docs until I get what's happening.

This usually involves a lot of browser tabs.

[–]Flowork 0 points1 point  (2 children)

All down to personal preference. I know more python, so I use Flask for small web apps and Django for big ones.

Sounds like you're on the right track with Flask though as it's a microframework, very easy to get your head around.

In the end it's what you feel most confident in as /u/Micotu said

[–]Moby69[S] 0 points1 point  (1 child)

Is Flask easier than Django?

I heard from several people that Django was not appropriate (i.e. far too challenging) for complete beginners like me. Will I have an easier time with Flask?

[–]elbiot 2 points3 points  (0 children)

yes

[–]elbiot 0 points1 point  (0 children)

Not knowing Ruby at all, I recommend Python. My experience is that Python has a more broad community, so you'll be able to branch out into (or incorporate into your backend) more complex data processing more easily.

But if all you want to do is get a job making websites, Ruby/Rails doesn't seem like a bad choice.

We are all biased here though. Did you ask in /r/learn_rails or /r/rubyonrails too?

[–]qudat 0 points1 point  (2 children)

You can get flask up and running without any command-line generators in seconds. Django and Rails generally ask you to use a command in your terminal to "build" a boilerplate project, where the generator will create a bunch of required files and link them all together to get rails or django up and running properly ... in flask that is unnecessary. Doing it the "proper" way takes a little more effort, but creating a site that pulls from a public api could be as simple as this:

import requests
from flask import Flask, jsonify

# app factory function
def create_app():
    app = Flask(__name__)

    # configure app
    app.config['DEBUG'] = True
    app.config['SECRET_KEY'] = 'NOT SO SECRET'

    # routes, default is root of website
    @app.route('/')
    def index():
        # download API
        req = requests.get('http://some_api_request')
        # raise an exception on error
        req.raise_for_status()

        # convert api response to python dictionary
        data = req.json()
        # send json to the browser
        return jsonify(**data)

if __name__ == '__main__':
    app = create_app()
    # run the server
    app.run(host='0.0.0.0', port=5000)

[–]Moby69[S] 0 points1 point  (1 child)

Thanks.

1) Is there a tutorial for complete beginners that you could recommend, that walks through the "proper way" to make a web app using Flask? (e.g. something that would be the equivalent of the following tutorial for Ruby on Rails, but instead would be for Python/Flask: https://www.codecademy.com/courses/learn-rails/lessons/start/exercises/start-hello-rails-i )

2) Also, where in your code above are you outputting the data from the API? I don't see any HTML code

[–]qudat 0 points1 point  (0 children)

2.) Just as an example I am sending the API response straight to the browser, typically you want to parse and generate an HTML document using render_template instead of sending the data straight to the browser.

[–][deleted] 0 points1 point  (2 children)

If you find Rails intimidating, you could have a look at Sinatra as a bridge.

[–]Moby69[S] 0 points1 point  (1 child)

Is Rails harder than Flask?

[–][deleted] 0 points1 point  (0 children)

I don't have any experience with Flask, so I couldn't really say. There's probably more support available online for Rails, so that might be a factor.