Flask Tutorial Web Development with Python 7- Dynamic Dashboard

sentdex · Beginner ·🛠️ AI Tools & Apps ·11y ago

Key Takeaways

This video tutorial by sentdex covers using Flask for web development, creating a dynamic dashboard, and extending templates with block body logic. It also touches on using Bootstrap for tabs and planning a content management system to generate HTML dynamically with Python logic.

Full Transcript

hello everybody and welcome to the sth Python Programming with flask and general web development tutorial video in this video we're going to be talking about the dashboard which is basically this right here so this is the Crux of this website this is where all the logic is and this is the main uh quote unquote web app uh for my website so let's get started so first of all what we need is we we need to have our header file which we've already created the header file we've just done nothing with it and then we'll have dashboard actually uh I want to say inherit from it but it it's going to extend using flask lingo the header file so first let's make this header so what we need to do is we're going to take main. HTML and I'm going to just go ahead and highlight All Copy come over to dashboard or no I'm sorry header and paste now what we're going to do is within our body uh we're going to we'll keep this div here and let's get rid of cuz again this is our header so what we want to do is we're going to keep that div we'll delete we'll delete the video within it uh we'll keep the scripts because those are going to be necessary uh and then what we're going to do is height 100% And instead of just height we're going to say Min height 100% so it can be taller if it needs to be uh and then we're also going to we'll convert this to a container fluid and now what we're going to do is first of all we can do we're going to add some logic here so we've got uh block body and then we're going to do basically some more logic and then we have end block now what this is is this is flask code and this is for when we do an extension uh which we're about to do for dashboard so I'll show you a little bit more about that in a moment now the only other thing I want to go ahead and have us add real quick is this border row so right now um you can see that um let's just save this real quick and now we're just going let's just add the Border row and I'll I'll point it out in a moment so it's going to be div class equals and it's border Das row and then whoops style equals width colon 100% And then we're going to add a bit of a margin so margin-bottom colon 15 pixels and that's it and then we'll go ahead and close off that div so this is our header file and now we can come over to to our dashboard and we're not going to add too much right now to this dashboard but for now this is going to extend or or what I would want to call inherit from the header uh but it's going to extend it and so to extend we're going to use some logic here and it's going to be extends and then you put in quotes what it extends this one extends header. HTML and again extends is going to search for templates within the temp templates directory so if it's extending a template that say in templates uh footer let's say uh you would add the footer in here so footer slash okay so just keep that in mind uh and I'm going to go and delete footer cuz we're not actually going to use that but it's extending header. HTML and then we're going to use the same uh text here so block body and block we're going to do again here block body and basically block body is going to go all the way to the very uh end where you would have end block so you've got block body and then uh and block whoops and block and then here we could just have maybe some quick paragraph tags and say hello okay oops almost knocked over my water save that that's dashboard it's extending header. HTML our header. HTML was a copy and paste of our other uh page there so everything should be fine up to this point let's check refresh good so we can see that our um the init.py that we have is uh where are you here you are uh right here it is dashboard and it Returns the template dashboard. HTML which is this this is all that template is but it has successfully extended this template entering basically all of the content on dashboard right here between the block body and it's enforcing this 100% although you don't really see it cuz we don't have a footer at the moment but it's there uh one more thing is let's see the Border Row for whatever reason appears to not be appearing what are you that is weird I thought that was we needed for a border um like a line in the Border what am I missing let me go let's go back here and cuz we want that I do want that border row uh let's see got dashboard we'll keep scrolling down okay it would be yeah would it wouldn't it not be this right here let's let's just copy this from the website and we will come over here paste save that that is header fresh ah it's odd would like to know what the dealio is there um okay well I'll look into that and see what the heck is happening here I don't really know why that would happen that's very frustrating to anyways um I'd like to have it but we'll just ignore that for now it's not essential and I'm tired of HTML at this point so we're going to continue along so Appo dashboard Okay cool so now what do we want to do well now at this point we want to have uh we know we have all this content that we want of course now we've got to return to you know HTML whatever so we're going to go to get bootstrap and we are looking for uh those tabs hoping I can just scroll through and see them uh I'm pretty sure they're in let's do uh nav D oops over here nav Dash tabs okay not those tabs is not what we want maybe it's these y these are the tabs that we want okay so food truck fixie oh RW denim you probably it's interesting uh random text they have here so this is this toggleable tabs tab. JS that which means we'll have to probably include that it's been a while since I wrote it uh and so we have this this is our tab content let's let just copy and paste this markup that they have here so copy we'll come over here we'll come to our dashboard and we'll just paste in those tabs that they've given to us thank you thank you let's see if they work okay the tabs at least work I don't see the uh fade effect but it looks like I see it right down down here uh so let me just copy and paste that again so the Fades will come back over here is right under it so now in the tab content you just add fade and you have an active tab which is you know your starting tab so come back over here and that was all the div so we'll just do this boom save that refresh I assume it would fade but it is just we've got no content and I don't see our oh there it is right here here so we do have our dot dot dot but it is over and I think what's happening is that's because of our Center do we have a yeah so we've got this align Center nonsense uh let's get rid of that we don't need to be centering any alignment uh and then um I wonder if that's what was causing our Pro no cuz we were right above that let me let's refresh this one last time there we go at least this stuff is over here now uh Min height and let's say let's see if we can get away with width 80% for now okay so uh we'll we'll come back to that as well I hate deal with CSS and stuff so anyway um so at least we have the tabs here we see that it is fading these dot dot dots for us so now we want to talk about how do we actually add content to these tabs so right now they say home profile messages settings let's let's change those so we'll come uh we'll save header we'll just leave header alone for a while refresh this okay still working so now we come over here and so the way this works is you've got the href which is pound home and then you've got home here and then this is just the the name that goes on the tab but then you'll want to change home and home here to be identical to basically home wherever this ID is so instead of home we let's call this Basics and then we'll literally just call these Basics as well the little hashtags uh and then the ARA controls Basics Basics and then uh basic stuff here okay we've got Basics let's do uh webdev so we'll call that wdev copy paste paste and we'll say webdev and let's just get rid of settings I don't feel like doing an a third or a fourth one and then finally we'll do uh data analysis and we'll call it Dan for data analysis paste paste paste and then uh data analysis okay so save hopefully those at signs don't screw us over nope okay so now you can see that okay we've got these tabs got custom content in the tabs awesome now what we want to do is actually work on our content management uh system and that's going to be how do we actually populate these tabs with content and then not only that but how do we maybe manipulate it over time so of course we could come in and we could say that the basics tab first let's delete this we're going to make some space here because each tab is going to contain some stuff so now of course we could come in and we could add some tags here for unordered list and then we could add you know list oops not lie list item SL list item and then we could have uh copy that paste paste uh part one part two and part three and we could really just you know handw write all of this stuff that's within here we can make them links into the tutorial but the problem is for let's say in a week you decide you want to add more stuff you want to take away maybe you want to reorganize this whole table so to an extent you you want to have some sort of content management system in the back end or the background that kind of drives what shows here plus we are using python the whole point of using python is to use logic where we can to generate the HTML so that's what we're going to be talking about in the next video is how we're going to build build a Content management system to take say a list of topics some URLs organize them for us and link to the pages in a very custom manner uh so that's what we'll be talking about uh in the next video if you do have any questions or comments up to this point feel free to leave them below otherwise as always thanks for watching thanks for all the support and subscriptions and until the next video

Original Description

sample code: http://pythonprogramming.net http://seaofbtc.com http://sentdex.com http://hkinsley.com https://twitter.com/sentdex Bitcoin donations: 1GV7srgR4NJx4vrk7avCmmVQQrqmv87ty6
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from sentdex · sentdex · 0 of 60

← Previous Next →
1 Matplotlib Python Tutorial Part 1: Basics and your first Graph!
Matplotlib Python Tutorial Part 1: Basics and your first Graph!
sentdex
2 Python Encryption Tutorial with PyCrypto
Python Encryption Tutorial with PyCrypto
sentdex
3 Python's Logging Function
Python's Logging Function
sentdex
4 wxPython Tutorials 1: Making Windows GUIs with Python : Installing + 1st window!
wxPython Tutorials 1: Making Windows GUIs with Python : Installing + 1st window!
sentdex
5 wxPython Tutorials 2: Making Windows GUIs with Python: Customizing Window Parameters
wxPython Tutorials 2: Making Windows GUIs with Python: Customizing Window Parameters
sentdex
6 wxPython Programming Tutorial 3: Menu Bar and Menu Button
wxPython Programming Tutorial 3: Menu Bar and Menu Button
sentdex
7 wxPython Programming Tutorial 4: Panels
wxPython Programming Tutorial 4: Panels
sentdex
8 wxPython Programming Tutorial 5: User Input Saved To Variables
wxPython Programming Tutorial 5: User Input Saved To Variables
sentdex
9 wxPython Programming Tutorial 6: Multiple Choice Input
wxPython Programming Tutorial 6: Multiple Choice Input
sentdex
10 wxPython Programming Tutorial 7: Adding Static Text and Colors
wxPython Programming Tutorial 7: Adding Static Text and Colors
sentdex
11 wxPython Programming Tutorial 8: Custom Button Images
wxPython Programming Tutorial 8: Custom Button Images
sentdex
12 wxPython Programming Tutorial 9: Tool Bar Items and Sub Menus!
wxPython Programming Tutorial 9: Tool Bar Items and Sub Menus!
sentdex
13 Basic PHP Tutorial 13: Multi-dimensional Array
Basic PHP Tutorial 13: Multi-dimensional Array
sentdex
14 Basic PHP Tutorial 15: Functions and Global Variables
Basic PHP Tutorial 15: Functions and Global Variables
sentdex
15 Basic PHP Tutorial 12: Associative Array
Basic PHP Tutorial 12: Associative Array
sentdex
16 Basic PHP Tutorial 14: Foreach loop
Basic PHP Tutorial 14: Foreach loop
sentdex
17 Basic PHP Tutorial 16: Include and Require
Basic PHP Tutorial 16: Include and Require
sentdex
18 Basic PHP Tutorial 7: Assignment, comparison and Logical operators
Basic PHP Tutorial 7: Assignment, comparison and Logical operators
sentdex
19 Basic PHP Tutorial 4: Variables and Comments
Basic PHP Tutorial 4: Variables and Comments
sentdex
20 Basic PHP Tutorial 11: Arrays part 1, basic array
Basic PHP Tutorial 11: Arrays part 1, basic array
sentdex
21 Basic PHP Tutorial 6: If else and else if conditionals cont'd
Basic PHP Tutorial 6: If else and else if conditionals cont'd
sentdex
22 Basic PHP Tutorial 1: Intro to PHP
Basic PHP Tutorial 1: Intro to PHP
sentdex
23 Basic PHP Tutorial 3: HTML with PHP
Basic PHP Tutorial 3: HTML with PHP
sentdex
24 Basic PHP Tutorial 9: While Loop
Basic PHP Tutorial 9: While Loop
sentdex
25 Basic PHP Tutorial 10: Switch Statement
Basic PHP Tutorial 10: Switch Statement
sentdex
26 Basic PHP Tutorial 2: Print and Echo
Basic PHP Tutorial 2: Print and Echo
sentdex
27 Basic PHP Tutorial 5: If else and else if conditional statements
Basic PHP Tutorial 5: If else and else if conditional statements
sentdex
28 Basic PHP Tutorial 8: Arithmatic Operators: Doing math with php
Basic PHP Tutorial 8: Arithmatic Operators: Doing math with php
sentdex
29 Basic PHP Tutorial 17: User Input Form Example / String Manipulation
Basic PHP Tutorial 17: User Input Form Example / String Manipulation
sentdex
30 Basic PHP Tutorial 18: HTML Entities and forms cont'd
Basic PHP Tutorial 18: HTML Entities and forms cont'd
sentdex
31 Basic PHP Tutorial 19: Finding words in strings
Basic PHP Tutorial 19: Finding words in strings
sentdex
32 Basic PHP Programming Tutorial 20: Saving to a File / writing and appending
Basic PHP Programming Tutorial 20: Saving to a File / writing and appending
sentdex
33 Basic PHP Programming Tutorial 22: Hashing part 2: salting
Basic PHP Programming Tutorial 22: Hashing part 2: salting
sentdex
34 Basic PHP Programming Tutorial 23: Variables in Strings and tokenizing
Basic PHP Programming Tutorial 23: Variables in Strings and tokenizing
sentdex
35 Basic PHP Programming Tutorial 21: MD5 Hashing For Security
Basic PHP Programming Tutorial 21: MD5 Hashing For Security
sentdex
36 Basic PHP Programming Tutorial 24: String similarity
Basic PHP Programming Tutorial 24: String similarity
sentdex
37 Basic PHP Programming Tutorial 25: Time and Time stamps
Basic PHP Programming Tutorial 25: Time and Time stamps
sentdex
38 Basic PHP Programming Tutorial 26: Die and Exit
Basic PHP Programming Tutorial 26: Die and Exit
sentdex
39 Basic PHP Programming Tutorial 27: MySQL Databases Part 1
Basic PHP Programming Tutorial 27: MySQL Databases Part 1
sentdex
40 Basic PHP Programming Tutorial 28: MySQL Database Part 2: Reading From Database
Basic PHP Programming Tutorial 28: MySQL Database Part 2: Reading From Database
sentdex
41 Basic PHP Programming Tutorial 29: MySQL Database Part 3: Inputting Data
Basic PHP Programming Tutorial 29: MySQL Database Part 3: Inputting Data
sentdex
42 Basic PHP Programming Tutorial 30: MySQL database in Use
Basic PHP Programming Tutorial 30: MySQL database in Use
sentdex
43 Django Tutorial Web Development with Python Part 1: Installing Django
Django Tutorial Web Development with Python Part 1: Installing Django
sentdex
44 Python Tutorial: File Deletion and Folder Deletion / directory deletion
Python Tutorial: File Deletion and Folder Deletion / directory deletion
sentdex
45 Python Tutorial: How to Rename Files and Move Files with Python
Python Tutorial: How to Rename Files and Move Files with Python
sentdex
46 3D Graphs in Matplotlib for Python: Basic 3D Line
3D Graphs in Matplotlib for Python: Basic 3D Line
sentdex
47 3D Plotting in Matplotlib for Python: 3D Scatter Plot
3D Plotting in Matplotlib for Python: 3D Scatter Plot
sentdex
48 3D Charts in Matplotlib for Python: Multiple datasets scatter plot
3D Charts in Matplotlib for Python: Multiple datasets scatter plot
sentdex
49 Sikuli Tutorial 1: Visually programming in python!
Sikuli Tutorial 1: Visually programming in python!
sentdex
50 Sikuli Tutorial 2: Program visually in python!
Sikuli Tutorial 2: Program visually in python!
sentdex
51 Sikuli Tutorial 3: Program visually in python!
Sikuli Tutorial 3: Program visually in python!
sentdex
52 3D Bar Charts in Python and Matplotlib
3D Bar Charts in Python and Matplotlib
sentdex
53 3D Plane wire frame Graph Chart in Python
3D Plane wire frame Graph Chart in Python
sentdex
54 Raspberry Pi Part 1 Introduction
Raspberry Pi Part 1 Introduction
sentdex
55 Raspberry Pi Part 8: First Download and Update! (Firmware)
Raspberry Pi Part 8: First Download and Update! (Firmware)
sentdex
56 Raspberry Pi Part 10: How to set up a Linux Web Server on your Pi
Raspberry Pi Part 10: How to set up a Linux Web Server on your Pi
sentdex
57 Raspberry Pi Part 11: Remote Desktop
Raspberry Pi Part 11: Remote Desktop
sentdex
58 Twitter Analysis: How to rank a user's influence
Twitter Analysis: How to rank a user's influence
sentdex
59 GPIO Tutorial for Pi Part 2 - Programming the GPIO
GPIO Tutorial for Pi Part 2 - Programming the GPIO
sentdex
60 GPIO Tutorial for Raspberry Pi Part 1 - Setting up
GPIO Tutorial for Raspberry Pi Part 1 - Setting up
sentdex

This video tutorial teaches how to use Flask for web development, create a dynamic dashboard, and extend templates with block body logic. It also covers using Bootstrap for tabs and planning a content management system to generate HTML dynamically with Python logic. By following this tutorial, viewers can learn how to build a web application with a dynamic dashboard and customize its content using Python logic.

Key Takeaways
  1. Create a header.html template
  2. Copy and paste main.html into header.html
  3. Delete unnecessary video element in header.html
  4. Add necessary scripts to header.html
  5. Set min-height to 100% in header.html
  6. Returns the template dashboard.html
  7. Extends the template with content between the block body
  8. Copies and pastes Bootstrap tabs into dashboard.html
  9. Pastes tab content into dashboard.html
  10. Adds fade effect to tabs
💡 Using Flask and Bootstrap can simplify the process of creating a dynamic dashboard and customizing its content. Planning a content management system to generate HTML dynamically with Python logic can take the web application to the next level.

Related AI Lessons

Up next
How to Open HPL Files (HP-GL Plotter)
File Extension Geeks
Watch →