Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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
Jeff Muday
Treehouse Moderator 27,419 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.

Brandon Galde
Brandon Galde
12,741 Points

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.