Web Development With Flask

Posted by
on under

You probably noticed that lately I haven't been blogging as frequently as I used to. Today I'm letting you in on my little secret:

Flask Book front page

I wish I could share the actual cover of the book featuring a cool animal, but for now the front page will have to do since the cover hasn't been designed yet.

So now you know. I'm writing a book on Flask. But what does that mean? How will the book be different from the Mega-Tutorial series?

When I wrote the first Mega-Tutorial article I didn't know how many articles the entire series would have, nor the specific topics I was going to cover. I just went with the flow and wrote about what I found interesting at the time. It was a learning experience for me.

Writing a book is much more difficult. I have to make sure that there is consistency (both in technical content and writing style) between all the chapters. It's like writing a single very long article that is published all at once and that must be as polished as possible from the start, since making corrections after publication, while possible, is a more complicated process than editing a blog post.

I expect there will be some similarities between the Mega-Tutorial and the book. The book will feature a web application, but it will not be microblog. The structure of the new application will be better than that of microblog, which grew organically as I developed it. I will make this new application available online as a demonstration at some point in the future. This is, of course, a dirty strategy. I will be showing you the eye candy to tempt you to go get the book!

Some of the topics I covered in the tutorial will also appear in the book, but there are a number of topics I did not feature in the series that will receive attention in the book. I haven't determined what the final structure of the book is yet, but I know the following topics are among those that will be covered in detail:

  • Databases
  • User authentication
  • Ajax and RESTful APIs
  • Administration pages
  • Hosting

I'm also interested in having some information on Web Sockets in the book, but haven't found a way to fit it with the rest yet. If it ends up not making the cut this will be material that will appear here in my blog.

I'm sure you now want to know when the book will be available. Since I'm working with a publishing house the schedule is not entirely up to me. I still have a lot of writing to do, but assuming things go as I have planned the book should be available both in print and as en e-book in Q1 of 2014. I believe the folks at O'Reilly Media are likely to make an early release available online for people to review and provide feedback, so I'll let you know when and if that happens.

If you want to stay informed about the developments around this book I invite you to visit http://flaskbook.com, the book's official website. There isn't much right now, but you can subscribe to receive notifications (this site is owned and operated by myself).

Alternatively you can connect with me in the usual ways:

These are exciting times for the Flask community. If the rumors I'm hearing are correct I expect in the following months you will have not one but several books to choose from!

Miguel

Become a Patron!

Hello, and thank you for visiting my blog! If you enjoyed this article, please consider supporting my work on this blog on Patreon!

20 comments
  • #1 Bambam said

    this is great news. I found your site not too long ago. I have been experimenting with a few python frameworks. I have a comment on your Mega Tutorial, I got lost in the "Followers, Contacts And Friends" and do we really need the testing?. Just two topics to consider expanding or perhaps making it easier for the reader to follow in your upcoming book. Anyways, I look forward to this new book and it would be nice if some sort of shopping cart examples were presented. Just my two cents. Thanks

  • #2 Miguel Grinberg said

    @Bambam: regarding the "do we really need the testing?" yes, unit testing ensures that existing functionality in your application does not break when you make additions or modifications. When something does break you want your own tests to catch the problem and not your users.

  • #3 Michael Le said

    AWESOME! You're mega tutorial helped me understand Flask and WebDev better. I'm excited about the new book, and congrats Miguel!

  • #4 Satish Viswanathan said

    This is real great news. I am eagerly looking forward to this book. Flask is an awesome framework and you, Sir, are an awesome writer. The combination would be lovely something to really look forward to.

  • #5 execute said

    I recommend you also include a chapter/section for Alembic to keep track of various database models.

    In addition, perhaps you can also talk about web hosts and how to get wsgi hosted python hosts like WebFaction, Heroku etc somewhere.

    The reason being: PHP's rise in popularity was mostly due to ease of deployment and hosting. Part of Flask/Python problem is database revision management and web hosting. I can't begin to describe the amount of web-host problems I ran into with python.

  • #6 Miguel Grinberg said

    @execute: Yes. Alembic is the migration tool of choice for the book. Hosting will also be covered, both traditionally and in the cloud. Note that there is some of that in the Mega-Tutorial as well, in particular I showed how to host on Heroku. The book will have the streaming solution simplified though, I have learned a few new tricks :)

  • #7 Mauricio de Abreu Antunes said

    Great news, Miguel.

  • #8 Steven Elliott said

    <h1>Awesome!</h1>

    If you're looking for early reviewers I'd love to help out!

  • #9 Hari said

    Really Great , I look forward to read the book.

  • #10 Steven Elliott said

    For the web sockets bit, would you be looking into Tornado or something else completely different?

  • #11 Miguel Grinberg said

    @Steven: well, that's the problem. The book is not about Tornado, so that would not fit into the book, in my opinion. I will be looking at writing a Flask extension that can make it look more Flask native, but I have a pretty short writing schedule as it is, so at this point this sounds like something I'll experiment with and show here on my blog at some point.

  • #12 Steven Elliott said

    Good point and it's probably a better option anyway. Regardless of what you decide, I am beyond excited to see what you're going to do. Thanks for all of your hard work helping out the Flask community. Without a doubt the best web framework tutorial I've ever seen and I really love the RESTful tutorials which I just finished.

  • #13 Micah said

    For the hosting, what will you cover? Standard shared hosting (with python support) would be great, otherwise you're stuck with 3rd party services like heroku, pythonanywhere or digitalocean (true they're great, since they let you deploy quickly, I myself am a fan of pythonanywhere, since you can code on a tablet + keyboard). But shared hosting would allow for a better IP address distribution of your projects etc

  • #14 Miguel Grinberg said

    @Micah: I also like regular hosting options better than cloud, I'm old fashioned that way. In the book I will try to cover both, the fact that pushing an app to Heroku or similar is so easy cannot be ignored. People like easy.

  • #15 David said

    Hi, It's perfect for me. I am IT administrator and I write more website from my company. I use bottle and flask, but it's a few tutorials like this.
    Ok it's possible translate this book to czech language ?
    I know it isn't language from more people :)
    Thankx

  • #16 scott said

    If it is anything like your tutorial, I'll be first in line. Excellent approach. Thanks

  • #17 Redian Ibra said

    I totally agree with you on unit testing which is great and it should be a must in any modern application.

    Something that would make your book stand out more from the rest would be an additional chapter on Front-end testing using unittest/splinter maybe you can also look into presenting your examples using saucelabs platform.

    Would definitely buy your book once out.

  • #18 skyway said

    Thank for your great book. I like it very much.But I have a problem. I run the server and request 'http://localhost:5000/' for the first time meet the error like, I have met this problem before, It's the problem in database model. But I don't figure out exactly. I trust your code have't this problem. Maybe my project configuration have some problem. Can you give me some solution ? Looking forward your reply.
    Traceback (most recent call last):
    File "C:\Program Files\Python\Python27\lib\site-packages\flask\app.py", line 1836, in call
    return self.wsgi_app(environ, start_response)
    File "C:\Program Files\Python\Python27\lib\site-packages\flask\app.py", line 1820, in wsgi_app
    response = self.make_response(self.handle_exception(e))
    File "C:\Program Files\Python\Python27\lib\site-packages\flask\app.py", line 1403, in handle_exception
    reraise(exc_type, exc_value, tb)
    File "C:\Program Files\Python\Python27\lib\site-packages\flask\app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
    File "C:\Program Files\Python\Python27\lib\site-packages\flask\app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
    File "C:\Program Files\Python\Python27\lib\site-packages\flask\app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb)
    File "C:\Program Files\Python\Python27\lib\site-packages\flask\app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
    File "C:\Program Files\Python\Python27\lib\site-packages\flask\app.py", line 1461, in dispatch_request
    return self.view_functionsrule.endpoint
    File "D:\Personal\Desktop\platform\flasky-master\app\main\views.py", line 51, in index
    query = Post.query
    File "C:\Program Files\Python\Python27\lib\site-packages\flask_sqlalchemy__init__.py", line 426, in get
    mapper = orm.class_mapper(type)
    File "C:\Program Files\Python\Python27\lib\site-packages\sqlalchemy\orm\util.py", line 661, in class_mapper
    mapperlib.configure_mappers()
    File "C:\Program Files\Python\Python27\lib\site-packages\sqlalchemy\orm\mapper.py", line 2263, in configure_mappers
    mapper._post_configure_properties()
    File "C:\Program Files\Python\Python27\lib\site-packages\sqlalchemy\orm\mapper.py", line 1172, in _post_configure_properties
    prop.init()
    File "C:\Program Files\Python\Python27\lib\site-packages\sqlalchemy\orm\interfaces.py", line 128, in init
    self.do_init()
    File "C:\Program Files\Python\Python27\lib\site-packages\sqlalchemy\orm\properties.py", line 911, in do_init
    self._determine_joins()
    File "C:\Program Files\Python\Python27\lib\site-packages\sqlalchemy\orm\properties.py", line 1048, in _determine_joins
    % self)
    ArgumentError: Could not determine join condition between parent/child tables on relationship User.followed. Specify a 'primaryjoin' expression. If 'secondar
    y' is present, 'secondaryjoin' is needed as well.

  • #19 Miguel Grinberg said

    @skyway: this is a problem in the way you have defined your models. You may want to read the relationships part of the SQLAlchemy documentation.

  • #20 skyway said

    I use the code downloaded form “https://github.com/miguelgrinberg/flasky” and haven't changed it.Do I need to change it according to SQLAlchemy document?

Leave a Comment