Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Flask Basics Templates and Static Files Flat HTML

Do you need Java Script still or can Flask take its place?

Do you still need Java script to make websites if you use Flask instead? Also can you still use / need HTML and CSS with Flask?

2 Answers

Jeff Muday
MOD
Jeff Muday
Treehouse Moderator 28,716 Points

The short answer-- you can definitely make good serviceable websites without JavaScript using Flask. Especially if you have some mastery of CSS and HTML.

Long answer-- If you don't include JavaScript, you end up having to perform page-reloads when there is a state-change. That may be fine for your purposes. But when you want pages to appear "live" or interact with more complex user mouse clicks and key-presses, or where you need partial rendering in-place without having to reload a page-- that is JavaScript territory. For example, suppose you want to show a list of stocks in a portfolio (with Flask) you can only grab the prices of the stocks just before you call flask.render_template() -- this works. But... if we add some clever JavaScript in an event-loop, the page could update prices every 2 seconds and make it look like a live-feed to the user.

In the real world, you're going to find JavaScript necessary for some client-side interactivity and validation. Things like drag-and-drop uploads, rich-text editors, live dash-boards, interactive graphs are client-side JavaScript. But like most modern programming, you can get this functionality from third-party libraries and not have to "re-invent the wheel."

There are great resources on Treehouse for learning a whole track of JavaScript. As a Python web programmer I would recommend watching these and maybe even do a bit of JavaScript server-side programming in Express/Node.js. It will make you a better web programmer and open you up to new worlds, and possibilities in web design.

I still use javascript for certain things since it is client side. I use jquery to make API calls to my flask server, which will then return content. I also use HTML and CSS quite a bit, flask is not a replacement for these things.