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

Akash malhotra
Akash malhotra
3,025 Points

Hard time understanding structure of web apps w JS frameworks?

I'm having a difficult time understanding how web applications work. Please help me understand without giving me google definitions. Baby steps/words would be appreciated =) From what I understand so far:

Okay so say we use Flask or Django ( python frameworks) for the backend.- This would be used as a base for our web app.Provides restful requests, some templating?

Then we would use HTML and CSS for the basic structure and styling needs?

Why do we need to use Javascript then. Does JS make the page dynamic,interactive,etc?, Like click of a button or something ( give me simple examples).

And then I see people using JS frameworks like Angular,react,ember, etc as a client-side framework. Can someone explain how the backend with python works with front-end with these kind of frameworks?

Like don't tell me what these frameworks are, tell me in simple words/examples what they actually do.

Flask+basic JS VS flask+angular ??

Can i still build an application that does simple things without using Javascript or (angular,react,etc)?

So in conclusion, please give me the ingrediants needed for a web app and what each piece does.

1 Answer

You've mentioned a few of the key concepts there.

Python is a server-side scripting/programming language. Flask and Django are frameworks that are built on Python, but help to get data of some sort displayed to users, usually with HTML, but you could also use them to build APIs for other applications to connect to instead. But you are correct that they take HTTP requests and then use that to determine what data/response should be returned to the user. Templates are used to dynamically change the content returned to the user based on the data or parameters that were sent with the request.

You'll generally need a database to go with a server-side/backend framework. Flask and Django can be configured to use many different types of databases with various plugins.

HTML is the structure of the page, CSS is the styling.

JavaScript in the browser is for client-side interactivity. Node.js is a server-side JavaScript technology that can achieve much of what Python can. Front-end frameworks like Angular, etc. just provide a ton of shortcuts for things that could essentially be accomplished with plain JavaScript, but would take a lot of time and effort. Each has different characteristics and advantages, so it really comes down to what they can help you achieve.

If you only need a basic level of interactivity, then perhaps plain JS or just jQuery would be enough. If, on the other hand,. you want a rich, dynamic user interface that operates quickly without having to load an entire new HTML page, then those frameworks can be very useful, particularly if you're changing content based on the data a lot.

There's no strict rule as to what you need for something to be classed as a web application. Technically it just has to make use of web technologies, and perform some task. You could even create an application in just HTML and CSS, though the functionality would be limited.

Not sure if my answer makes anything clearer or just provides you with more questions, so feel free to keep the conversation going! Kenneth Love might have some input...

Akash malhotra
Akash malhotra
3,025 Points

Thanks Iian, makes things a lot more clearer. So the only reason we use Flask is to return the data response from an external API OR use it if I need a database? And then once I call an API using python, I'll have to display it to the user in an interactive way ( which is where html,css, and angular come in?)

I'm still confused on what kind of apps require databases VS apps that don.t. So like everything that requires you to log in, make a post/comment, manipulate that post/comment, a to-do list, all these require databases if I'm understanding this right?

What would be an example of an app that doesn't require any database? An example of an app that doesn't require any backend language?

If you haven't already done it, have a look at the Database Foundations course here on Treehouse. The start of it explains when you might want to use a database, and when you wouldn't.

So an example of an app that doesn't need a database would be the character builder (bear) app that was in the Flask Basics course. It just uses cookies in the user's browser to store small amounts of information. In this case, the amount of information is small, doesn't have any privacy or security concerns as such, and doesn't need to persist for a long time or outside of the browsing session for that user.

Generally, if you're not storing information in a database, you would store it in files, or just in memory in the browsing session.

As for apps that don't need a backend language, a good example is the drawing application in the jQuery Basics course. It uses jQuery, the most popular library for JavaScript, and the HTML5 canvas element to allow the user to draw something, change pen colours, etc.