Flask Tutorial #10 - Blueprints & Using Multiple Python Files

แชร์
ฝัง
  • เผยแพร่เมื่อ 8 ม.ค. 2025

ความคิดเห็น • 111

  • @kimeg7294
    @kimeg7294 4 ปีที่แล้ว +73

    It's always interesting to see how number of viewers drop as we progress towards the end of pretty much all programming series out there. The law of statistics never disappoints.

    • @nidhishprasad2506
      @nidhishprasad2506 4 ปีที่แล้ว +4

      Yes it with all the tutorials.Longer the tutorial more the drop.

    • @bogdanmind3271
      @bogdanmind3271 3 ปีที่แล้ว

      Nice notice, ty!

    • @Maxtron
      @Maxtron 3 ปีที่แล้ว +1

      Dunning kruger effect

  • @kishoreandra
    @kishoreandra 5 ปีที่แล้ว +34

    This is what we need more after referring docs .....Thanks Tim....wish you would do more videos on Flask like this.....

    • @kishoreandra
      @kishoreandra 3 ปีที่แล้ว

      @Kristian Uriel howz this relevant loll

  • @SoBasicCat
    @SoBasicCat 3 ปีที่แล้ว +53

    Hey Tim, i wanted to point out that when you use CSS as for blueprint you have to change href="{{url_for('static',filename='style.css')}} to href="{{url_for('second.static',filename='style.css')}} when referencing the CSS code. Thank you very much for your videos, i have learned a lot😀 from them

    • @joaoguilhermezatiribeiro6060
      @joaoguilhermezatiribeiro6060 3 ปีที่แล้ว

      Thanks bro, my custom css was not working and I became to wonder why. Then I did what you said and works fine =)

    • @prog_free_time421
      @prog_free_time421 3 ปีที่แล้ว

      Thanks a lot, image was not loading but now thanks to your comment it does.

    • @alinan485
      @alinan485 2 ปีที่แล้ว

      Thanks from 💙💛

    • @yiti8293
      @yiti8293 2 ปีที่แล้ว

      thanks👍

    • @Quannguyen-ci9pw
      @Quannguyen-ci9pw 2 ปีที่แล้ว

      thanks a lot for that bro

  • @svijayiitk
    @svijayiitk 5 ปีที่แล้ว +6

    You make the best python videos in the world! I recommend your channel for python learners. Thanks again!

  • @andrewmathenge3400
    @andrewmathenge3400 ปีที่แล้ว

    Best explained tutorial on Blueprints that I've seen. Very concise, and covers so much in 13 minutes. Super.

  • @jeffjackson2574
    @jeffjackson2574 3 ปีที่แล้ว +2

    Thanks for explaining it so clearly! All the documentation I was reading kept talking about app factories; this is a much clearer way to explain the basics.

  • @adesuamartins8527
    @adesuamartins8527 2 ปีที่แล้ว +1

    This guy is definitely the best python youtuber

  • @TheDr660
    @TheDr660 3 ปีที่แล้ว

    This was immensely helpful, read through the docs and was confused. You are awesome.

  • @davidfuchs86
    @davidfuchs86 3 ปีที่แล้ว +20

    Hi Tim,
    thanks for this great tutorial. I very much like the way you introduced us to flask.
    One thing that may be helpful to others: For me, it did not work instantly for the blueprint to access the static folders, i.e. I had an issue both showing the image and loading the css file. Finally, I found I had to change the variable 'static' in the url_for argument to 'second.static' for everything to work...

  • @m12652
    @m12652 3 ปีที่แล้ว +1

    For anyone who’s migrating templates for a complex app structure... flask adds the package specific templates to the search path as opposed to just making the package look internally. This means if you have multiple templates with the same name, e.g. home.html, it will render the first one it finds...

  • @prog_free_time421
    @prog_free_time421 3 ปีที่แล้ว +1

    Thank you so much, Tim, for all your tutorials, they are amazing!

  • @terribleturtles
    @terribleturtles 5 ปีที่แล้ว +1

    Nice seeing all this Flask content, Tim!

  • @justinlee3453
    @justinlee3453 4 ปีที่แล้ว

    Thanks Tim, these series really gave me a kickstart for my project !!

  •  4 ปีที่แล้ว +1

    Thanks, nice content :) Hi from Turkiye!

  • @TecnoTutosMarc
    @TecnoTutosMarc 3 ปีที่แล้ว +1

    You are the best because I was looking for what is init and why, how uses it 💪💪

  • @nathant5067
    @nathant5067 4 ปีที่แล้ว

    Its crazy how much i can learn for free just on youtube!!

  • @siamakshams1923
    @siamakshams1923 2 ปีที่แล้ว

    Yet another fantastic tutorial. Thank you.

  • @blackcat-xu3ph
    @blackcat-xu3ph 4 ปีที่แล้ว

    Wow I really liked this video man, very simple but still very good ! thank you

  • @Vue-daigle
    @Vue-daigle 4 ปีที่แล้ว

    Thks Tim ! Great videos, nice and clear ; can't wait for the next ones.

  • @besttechnews
    @besttechnews 4 ปีที่แล้ว +2

    Just Awesome, Bro!

  • @Julian-tf8nj
    @Julian-tf8nj 4 ปีที่แล้ว

    superb tutorial - very clear and concise - thank you!

  • @trakba
    @trakba 10 หลายเดือนก่อน

    at 11:24 wouldn't our import statement be "from admin.template import second" ?

  • @eduardogil1775
    @eduardogil1775 3 ปีที่แล้ว

    Excellent explanation, Thanks for sharing 👍🏽

  • @MrBebopbob
    @MrBebopbob 3 ปีที่แล้ว

    Very nice beginners tutorial. Thanks

  • @hekote2112
    @hekote2112 2 ปีที่แล้ว

    This is a really great tutorial. help me a lot.

  • @mahatechtalks9496
    @mahatechtalks9496 3 ปีที่แล้ว

    Hi Tim
    Thanks for the video and it was very useful

  • @aqibfayyaz1619
    @aqibfayyaz1619 4 ปีที่แล้ว

    Thank you this is what i was looking for.

  • @hassansuhaib9087
    @hassansuhaib9087 4 ปีที่แล้ว

    Thank you so much for making these tutorials!

  • @helluci6449
    @helluci6449 4 ปีที่แล้ว +1

    No matter if I add the template_folder / static_folder, its gonna use the default ones. for ex., I said "template_folder="admin_templates", but when I entered localhost:5000/admin/ , it rendered the index.html in the "templates" folder, not the one in "admin_templates".

  • @mbonuchinedu2420
    @mbonuchinedu2420 2 ปีที่แล้ว

    God Bless you tim. 🔥🔥🔥🔥

  • @DeenQuery
    @DeenQuery 3 ปีที่แล้ว

    well explained; thanks man 👍

  • @veronicakanczes571
    @veronicakanczes571 3 ปีที่แล้ว

    Thank you for demonstrating!

  • @lonnybulldozer8426
    @lonnybulldozer8426 5 ปีที่แล้ว +1

    If anyone is curious, this kid's name is REDACTED_FOR_PRIVACY. I like to find peoples' names who don't seem to want to make them available. That's REDACTED_FOR_PRIVACY, folks.

    • @TechWithTim
      @TechWithTim  5 ปีที่แล้ว

      Lol it’s pretty easy to find my name

    • @lonnybulldozer8426
      @lonnybulldozer8426 5 ปีที่แล้ว +1

      @@TechWithTim Yeah, for me. It's what I do. It took me all of 30 seconds, though. I've unearthed some pretty hidden people, which took years of research and investigation. I'll go ahead and change my comment, though. I don't like to put people on blast. Or do I?

  • @nomisotech9498
    @nomisotech9498 5 ปีที่แล้ว +1

    Hi Tim! Can you make a video about the software you use?

  • @houda9434
    @houda9434 5 ปีที่แล้ว

    what a great tutorial, keep it up

  • @chilin2314
    @chilin2314 3 ปีที่แล้ว

    good tutorial video, thank you!

  • @ahmedlimam2241
    @ahmedlimam2241 4 ปีที่แล้ว

    can you like for example share sessions between the two python files? or do you need some external file?

  • @igorcrissaff1583
    @igorcrissaff1583 2 ปีที่แล้ว +1

    how can use mysqldb in these blueprints?? i can create the mysql connection on the main file, but i can't do it with the blueprints

  • @harshabiyani1523
    @harshabiyani1523 2 ปีที่แล้ว

    Thanks for the session. Can we add Blueprints in flask classify? if yes, how can we add the same?

  • @JaySecurity
    @JaySecurity 5 ปีที่แล้ว

    After setting up the separate folders with their own templates and static can you still extend from the main app. Eg. Main app has a layout.html has a top bar nav. Main section with a block content and footer and extend that out to an admin/templates/login.html

  • @Imufur
    @Imufur 3 ปีที่แล้ว

    very useful, i made a small app but the main file was getting huge, this is like the html files and js files where you import the js file instead of putting all the js code inside the html right?

  • @jayantkeer3416
    @jayantkeer3416 2 ปีที่แล้ว

    Nice explanation

  • @constantinewesterink3845
    @constantinewesterink3845 4 ปีที่แล้ว +1

    will i be able to get data from my db created in another file?

  • @westernvibes1267
    @westernvibes1267 5 ปีที่แล้ว +2

    Dude can you do data structures implementation in python and take it to Advanced level? Or strech your artificial intelligence course to Advanced. Need em badly , i learned a lot lot from you

  • @Aliabbashassan3402
    @Aliabbashassan3402 3 ปีที่แล้ว

    I already reading qr code using flask and check it if it is accommodate thr png picture. But how can go to another html page after that

  • @shivamjalotra7919
    @shivamjalotra7919 4 ปีที่แล้ว

    Thanks, loved it

  • @xandresglx
    @xandresglx 4 ปีที่แล้ว

    Hi Tim,
    Thanks for your videos!
    Not sure if you could help me with the problem I am having...
    I am trying to display in a loop, all the images I have in a folder called 'images' under the folder 'static'
    if the images are into the folder 'images' are not displaying but if the images are in the folder static are displaying.
    This is what I got and it's working when the images are in the root of the folder 'static'
    {% for image_name in image_names %}
    {% endfor %}
    but I would like to put the images in the folder 'images'.
    How do I add '/images/ in the path?
    I have tried diferent ways but not succes
    Thanks,

  • @vanlalmuanpuiaralte540
    @vanlalmuanpuiaralte540 5 ปีที่แล้ว

    thanks for the video 👍👍👍👍

  • @joplayfull4592
    @joplayfull4592 5 ปีที่แล้ว +5

    After i moved my folders and the second.py the styles.css and the image does not work anymore. Do you know why and how to fix it?

    • @philipwerz
      @philipwerz 4 ปีที่แล้ว +1

      @@bve6198 it still doesnt work for me. Any other ideas?

    • @Mammut7777777
      @Mammut7777777 4 ปีที่แล้ว +5

      I had the same problem. I got 404 for static files: "/static/styles/style.css HTTP/1.1←[0m" 404"
      I found the solution here: github.com/pallets/flask/issues/348
      I had to use a period (.) before static in the .html files to solve it: "{{url_for('.static', filename='styles/style.css')}}"

  • @DanielWeikert
    @DanielWeikert 5 ปีที่แล้ว

    Do you import second from "second=" or the "second" used withing the Blueprint as name? So if I do not like to use second and second but 2 different names? Thanks

    • @TechWithTim
      @TechWithTim  5 ปีที่แล้ว

      From file name import variable name

  • @anujkondhalkar9776
    @anujkondhalkar9776 4 ปีที่แล้ว

    Respected sir,
    I have one question that is , Why blueprint instance have same name as a first argument in it. e.g. = Blueprint('second', __name__).
    why "second" repeated two times. are those two different. thank you.

  • @MrJorjantas
    @MrJorjantas 3 ปีที่แล้ว

    ¿How to pass mysql cursor as a blueprint argument? This is needed for database operations inside the routes functions

  • @bhargavkhetmalis3886
    @bhargavkhetmalis3886 ปีที่แล้ว

    Hi! Can I use flask for big projects? (practice)

  • @FilthySnob
    @FilthySnob 3 ปีที่แล้ว

    i dont get why when i remove the __init__ from my blueprint folder, things continued to work as expected?

  • @abhaykumar0215
    @abhaykumar0215 2 ปีที่แล้ว

    Could you please do the same like creating multiple modules for flask_sqlalchemy....not able to find much helpful video

  • @KittichaiKerdsongsang
    @KittichaiKerdsongsang ปีที่แล้ว

    After I moved the static and templates folder to the admin folder, the images and CSS files were not working. Could someone please explain?

  • @anassfaiz5098
    @anassfaiz5098 ปีที่แล้ว

    why the css file is not working in the home.html i made a image and a text with css code but i doesn't work and i don't know why is not working

  • @slavkodem70
    @slavkodem70 5 ปีที่แล้ว +1

    Nice tutorial, kinda wish you also posted the source code for all your files, that would be nice

  • @eyal9664
    @eyal9664 5 ปีที่แล้ว

    Will you make tutorials on 3d games?

  • @darthvader4899
    @darthvader4899 4 ปีที่แล้ว

    how do you use session between different files?

  • @sau002
    @sau002 ปีที่แล้ว

    Excellent

  • @lavatech2092
    @lavatech2092 5 ปีที่แล้ว

    cool tutorial

  • @Aliabbashassan3402
    @Aliabbashassan3402 3 ปีที่แล้ว

    How can I read a qr code for login flask app.. Please help

  • @rafacoluccijf
    @rafacoluccijf 4 ปีที่แล้ว

    Just adding a note: since python 3.3 there is no need for an empty __init_py file anymore when creating a module. www.python.org/dev/peps/pep-0420/

    • @HubertRozmarynowski
      @HubertRozmarynowski 3 ปีที่แล้ว +1

      You probably meant a package. A module is just a python file.
      There is no need for an empty __init__.py to import from a folder, but to make things simpler for future reuse of the contents of the folder as a library, you can specify imports inside the __init__.py file in a following syntax:
      from package.module import object
      And later in main, you would just:
      import package
      To use the actual contents of the package, you would use the syntax:
      variable_from_the_package = package.variable1
      instance_of_a_class_from_the_package = package.Class1()

    • @rafacoluccijf
      @rafacoluccijf 3 ปีที่แล้ว

      @@HubertRozmarynowski You are 100% right. Thank you very much for the information.

  • @en_coded
    @en_coded 3 ปีที่แล้ว

    cant we just import without blueprint ?

  • @NardiPaffon
    @NardiPaffon 4 ปีที่แล้ว

    what is I wanted to have /admin/something/somethingelse ?

    • @aaronhe6877
      @aaronhe6877 4 ปีที่แล้ว

      @second.route('/something/somethingelse') try that

  • @mohanapriyaprithvi1365
    @mohanapriyaprithvi1365 4 ปีที่แล้ว

    hello tim can we change the website name????????????

  • @johngiles6930
    @johngiles6930 4 ปีที่แล้ว

    Wheres the "link in the description"?

  • @kick_8742
    @kick_8742 5 ปีที่แล้ว

    Hello may i know what packages are you using in your Sublime Text Editor?

  • @colinclarke9990
    @colinclarke9990 4 ปีที่แล้ว

    Hey Tim, thank you for this I've really enjoyed it. I've been following your ML stuff also and I saw on one of your projects vids that you were able to run your recognising handwritten digits code on the browser. I've written code that allows you to classify a digit you draw using a model you have saved but I coded it using Pygame. Is there an easy way of running pygame code on a browser or did you write yours in JS or other?

  • @anurajms
    @anurajms 2 ปีที่แล้ว

    thank you

  • @_m_m9214
    @_m_m9214 2 ปีที่แล้ว

    thank you my black brother\

  • @SarvErikaXp
    @SarvErikaXp 4 ปีที่แล้ว

    routes
    __init__.py
    home.py
    about.py
    templates
    home.html
    about.html
    necesito que sean separados algo parecido
    I need something similar to be separated

  • @lavatech2092
    @lavatech2092 5 ปีที่แล้ว

    do have a patreon account

  • @eventeklay4618
    @eventeklay4618 4 ปีที่แล้ว

    How many thing do you know you know how to make web app u know how to make GUI app u know to make mobile app bro

  • @marcelobarros5073
    @marcelobarros5073 4 ปีที่แล้ว

    How my blueprint access objects in the main app?
    How my blueprint access the database?
    How my blueprint access the main app's config?
    Your tutorial only works for static webpages, nothing more.
    You did not explaing anything about "context" or using "current_app". If you don't want to talk about it, at least leave a warning for people to know they have to look for more information.
    I hope that when people try to convert their apps through your tutorial, they find out quickly it is incomplete. So, they won't expend too much time thinking their code is broken.

  • @لنتسقطامةرسولهامحمدوصاحبهعمرال

    FLASK IS MOR BETTER THAN DJANGO.................................DJANGO HAS MANY COMPLICATED BAGAGES........BUT FOR SERVER STUFF AND EASY CLEARLY ALGORITHMUS PHP STAY THE BEST

  • @alvinnlus
    @alvinnlus ปีที่แล้ว

    Better spelling NOT included. Spell Tripple again!