Flask Tutorial #4 - HTTP Methods (GET/POST) & Retrieving Form Data

Поділитися
Вставка
  • Опубліковано 22 лис 2024

КОМЕНТАРІ • 205

  • @Brianccards
    @Brianccards Рік тому +7

    Unbelievably helpful. Watched a few of these videos and I feel like I learned a ridiculous amount in just one day. Went from 0 knowledge of HTML and flask with basic python to feeling like I can make any website lol

  • @asyaevloeva1270
    @asyaevloeva1270 4 роки тому +90

    omg this is such a great tutorial!! i wasted 2 days trying to make my post/get methods work and was about to give up haha but fortunately i found this video! thank you for such a clear explanation!!!

  • @longkesh1971
    @longkesh1971 Рік тому +8

    Exactly what I needed for an example of how to use an HTML form with flask. I really appreciate how you provide a simple example and keep it to around 10 minutes. Thanks man, I'm trying to do my college homework for Python class and this was great.

  • @anirvinvaddiyar7671
    @anirvinvaddiyar7671 4 роки тому +50

    I just watched this video 3 times to figure out that my post method wasnt working because I put "methods" in the html form attribute instead of "method".....i love coding so much

  • @haozhe3237
    @haozhe3237 4 роки тому +18

    The clearest video on this topic I have seen so far. Thank you so much Tim. Really helpful and understandable for us absolute beginners.

  • @Warclimb64
    @Warclimb64 2 роки тому

    thanks! I was stuck all afternoon trying to connect a form and I solved it right away with your video.

  • @jonathanmantello3974
    @jonathanmantello3974 Рік тому +1

    Love how you give context to the content and what you're doing, great tutorial!

  • @Astr0B
    @Astr0B 5 років тому +1

    This guy is a sick lad. Does't worry about or-complicated explanations and just gets straight to the point

  • @kylerbriskey372
    @kylerbriskey372 3 роки тому +4

    I really wanna move onto the next video but I had to stop and comment and say how great these videos are. This is EXACTLY what I've been looking for! Thank you SO much!
    I'll be watching the videos in order, but hopefully you have a video the covers how to upload file to the server I can run functions on. If not maybe, you can make a video. It's something I've been stuck on for a while now. Thanks!!!

  • @TheGiant225
    @TheGiant225 3 роки тому

    You saved me after 9 hours of coding your the best thank you thank you thank you

  • @dorianvedel1910
    @dorianvedel1910 4 роки тому +3

    You don't know it but you're becoming my hero !

  • @nitinkashyap1821
    @nitinkashyap1821 2 роки тому

    I am very glad that you have created these videos on this topic. this just saved me from failing a class.

  • @holycowss
    @holycowss 3 роки тому +15

    Your videos are very user-friendly and easy to follow along with! You have helped me more than I could say! Thanks for all your hard work and dedication!

  • @ryanfields1533
    @ryanfields1533 3 роки тому +3

    This video is great. I am a SQL developer, so python and HTML are a side gig for me. I was struggling with taking in input from a flask server and passing it to other functions but you have explained everything in a way that is both easy to understand and is translatable to my application's needs. Thanks so much!!!!

  • @imadoulhou7854
    @imadoulhou7854 5 років тому +20

    much appreciate Tim! hope to see deep and advanced tutorials about Flask..

  • @bisthenickel
    @bisthenickel 3 роки тому

    I did this because yes.
    I put some pride into my work and merged the RENDER_TEMPLATE function with a dictionary called CONTENTS that is basically configuration.
    Here is script Number 1
    from flask import Flask, redirect, url_for, render_template
    from settings import contents
    def rendertemplate(name):
    return render_template(name, contents=contents)
    Here is script Number 2
    contents = {
    "forListTest":["This", "is", "a", "test."],
    "title":"Trebla2"
    }
    Please note that this is super early on, so some of this is probably gonna change when i finish.

  • @manvelbeaver520
    @manvelbeaver520 4 роки тому +1

    Very helpful video for figuring out how to use Get and Post requests with Flask. Thank you very much.

  • @manasvinsharma1740
    @manasvinsharma1740 4 роки тому +1

    Brief and brilliant explanation.

  • @sanjevsplay4396
    @sanjevsplay4396 2 роки тому

    Great material and finally I learnt to develop a web application!

  • @carecavoador
    @carecavoador 5 років тому +21

    Hey, Tim. Would you mind showing us what packages have you installed on your Sublime Text?

  • @Clasher_7617
    @Clasher_7617 3 роки тому

    dude thanks so much, i wanted to know how to make buttons for my webpage and now it works thanks man

  • @exoticme4760
    @exoticme4760 3 роки тому

    Thank you so much, You saved my life. I hope your channel grow more & more

  • @nakamiakprossy7675
    @nakamiakprossy7675 3 роки тому

    Thanks bro u r da best Tim. I really appreciate this because i have advanced alot

  • @mehulrana9485
    @mehulrana9485 4 роки тому +5

    This is really helpful. Thanks Tim, very clearly explained.

  • @samsmusichub
    @samsmusichub 4 роки тому

    There goes my hero. Watch him as he goes!

  • @mouadtaoussi42
    @mouadtaoussi42 5 років тому

    Best Instructor Ever !!

  • @zdravkogospocic9244
    @zdravkogospocic9244 Рік тому +2

    I dont get it why do you have also and base.html and index.html, can you show them and what is difference between this 2, great video, but I am confused with 3 html files insed of 2

  • @Dan-codes
    @Dan-codes 3 роки тому

    This saves tons of time, thank you.

  • @Villentrethenmerth
    @Villentrethenmerth 2 роки тому +1

    The key difference between GET and POST - GET doesn't have request body. That's why POST is secure - you can send encrypted data .

  • @odinsrensen7460
    @odinsrensen7460 Рік тому

    this is exactly what I needed.

  • @nakamiakprossy7675
    @nakamiakprossy7675 3 роки тому

    Please Tim IOT toturials plz .I trully really like and follow your Tutorials

  • @gustavoaurelio1
    @gustavoaurelio1 3 роки тому

    unbelievebly understandable, congrats!

  • @abhinav9561
    @abhinav9561 3 роки тому

    Thanks buddy. The videos were really helpful. To the point and informative as hell.

  • @JW-nr3zo
    @JW-nr3zo 3 роки тому

    this is so good. great work! bless your day

  • @sabuein
    @sabuein 2 роки тому

    Thank you so much, very helpful.

  • @teclote
    @teclote Рік тому

    Very clear, thank you.

  • @rmatveev
    @rmatveev 2 роки тому +1

    I think that it is a kind of bad practice using "/" URL. What if your username will be equal to "login"?
    The better way is to use URL like "/user/" which will never collide with "/login" or any other pages we would have in the website root.

  • @minindusheheran6624
    @minindusheheran6624 4 роки тому +1

    Thank you, Really appreciate your work..!

  • @prachiarora3180
    @prachiarora3180 4 роки тому

    Hey Tim your video has been a great help to me but can you tell me how can I show the output on same page below my form when I click the button.

  • @marcin_lewandowski
    @marcin_lewandowski 11 місяців тому

    Thanks a lot Tim

  • @codewithlenny
    @codewithlenny 4 роки тому

    Simple and Clear. Thanks a Lot

  • @CharleswoodSpudzyofficial
    @CharleswoodSpudzyofficial 3 роки тому

    Thank you for this awesome tutorial!

  • @TechnicalAnkesh
    @TechnicalAnkesh 3 роки тому +1

    Appreciate your work keep it up!

  • @originalbinaryhustler3876
    @originalbinaryhustler3876 Рік тому

    God bless you bro ❤

  • @tymothylim6550
    @tymothylim6550 3 роки тому

    Thank you very much for this video! It was very educational for me :)

  • @RoryDavidWatts
    @RoryDavidWatts 3 роки тому

    this is an excellent series, thank you Tim

  • @barungh
    @barungh 5 років тому

    Waiting for next video impatiently ...

  • @helmialfathseptiana6383
    @helmialfathseptiana6383 4 роки тому

    so clear. thx , Tim.

  • @JohnLoydMadrinian
    @JohnLoydMadrinian 9 місяців тому

    salamat dok sa inyo
    salamat sa pagtulong niyo
    pag-aalaga ay tapat at totoo
    maayos na kalusugan
    buong hangad kanino man
    sa bawat pilipino'y kayo ang takbuhan
    kaya't salamat dok
    sa pagtulong na lubos
    kalusugan namin naging maayos
    salamat dok sa inyo
    nakagabay lagi kayo
    impormasyong hatid laan sa bawat tao
    salamat dok sa inyo
    salamat sa pagtulong niyo
    pag-aalaga ay tapat at totoo
    maayos na kalusugan
    buong hangad kanino man
    sa bawat pilipino'y kayo ang takbuhan
    salamat dok (5x)

  • @ga1z0
    @ga1z0 2 роки тому

    absolute legend ty so much!!!

  • @aminalamdarloo349
    @aminalamdarloo349 2 роки тому

    Dear bro
    Tnx for your video .
    I need to know how i can appear the captcha code in busy or overloaded sites when tis not shown captcha code ( just show the image box instead off captcha code) by get and post method.

  • @sergeichwelcome
    @sergeichwelcome 4 роки тому

    Thanks for your lessons!

  • @paulborstorf9538
    @paulborstorf9538 3 роки тому

    Amazing tutorial

  • @maximdongur-ool2226
    @maximdongur-ool2226 4 роки тому

    guys! its important. When you copy Navbar, CSS and JS you have to use version Bootstrap v4.3. Now at 2020 October its v 4.5
    new version makes lots of problem when you try Login with method POST

  • @dilshodusmanov1458
    @dilshodusmanov1458 7 місяців тому

    best video tutorial

  • @rohitkumarz
    @rohitkumarz 4 роки тому +3

    Thank you so much for the videos learning a lot...:)
    lol @6:13

  • @sanicspeed1672
    @sanicspeed1672 9 місяців тому

    If youre having trouble with errors check task manager and see if there arw any python files running in background

  • @ioannisventouzis
    @ioannisventouzis 4 роки тому +1

    Thanks for the great video Tim. Can you please explain how we can get more than one value in the login route if the form has more input tags?

    • @ArvindaSudan
      @ArvindaSudan 4 роки тому +1

      have you found the solution to pass 2 values?

    • @ArvindaSudan
      @ArvindaSudan 4 роки тому +1

      found a way to resolve this..
      You have to parse the multiple parameters with the url (using javascript redirect option).. then when it has been redirected to your app route, then
      var 1 = request.args.get('your_param_name1')
      rvar 2 = equest.args.get('your_param_name2')

  • @bogdanmind3271
    @bogdanmind3271 2 роки тому

    Fantastic lesson, you helped me a lot. Thank you so much!

  • @adrianb1823
    @adrianb1823 4 роки тому

    what a legend, very helpful

  • @webdev10000hours
    @webdev10000hours 4 роки тому +1

    How would you go about adding posts/blogs?

  • @DevinaArvind
    @DevinaArvind 4 роки тому +1

    Great video. My doubt is that I need to send a value selected from a drop down as a GET parameter to my Flask backend. How do I do that? Here you used the function request.form[id] but I need to pass a variable (or parameter) which I would select from a dropdown list.

  • @korhan1241
    @korhan1241 3 роки тому +1

    This gives me error as "The method is not allowed for the requested URL." even if i wrote exactly the same code.

  • @BlueBloodGamerz
    @BlueBloodGamerz 3 роки тому

    If we on vsc will we choose pyton Or html for working?

  • @UdayadityaSankarDas
    @UdayadityaSankarDas 10 місяців тому

    won't giving # in action cause problems later? What should we put in its place?

  • @unchart_d
    @unchart_d 5 років тому +1

    Thank you brother for this tutorial.

  • @siddhanthmetla9638
    @siddhanthmetla9638 4 роки тому +3

    What is the purpose of "/" before the closing tags?

    • @ahmedmahboub2199
      @ahmedmahboub2199 4 роки тому +1

      input is a self closeing tag

    • @_b0mbix_
      @_b0mbix_ 4 роки тому +4

      I heard that isn't necessary (HTML works with and without "/"). However, if u want to have page compatibile with XHTML, u need all closing (/) tags, even in sth like input, br and img

    • @ebrargenc4611
      @ebrargenc4611 4 роки тому

      @@_b0mbix_ thanks

  • @JacMaciag
    @JacMaciag 5 років тому

    Cool, thx for this. I was working on a Flask app recently and this, I hope, will validate I did something good :) Waiting for more episodes.

  • @zt.5677
    @zt.5677 3 роки тому

    Interestingly, I have left the re-route function from the previous video in the code and the POST, GET function re-route uses that one instead of the one I have created for it. Wonder why?

  • @bilalkhann16
    @bilalkhann16 3 роки тому

    Thanks Tim!

  • @rasinthemarasinghe5229
    @rasinthemarasinghe5229 Рік тому

    If we need to transmit large data through a redirect, how can we do that? I encountered an 'ERR_RESPONSE_HEADERS_TOO_BIG' error when attempting to pass the data.

  • @vijeandran
    @vijeandran 2 роки тому

    HI, Instead of printing all the columns in GET request, How could I get only specific columns from the postgres table?

  • @hangchen
    @hangchen 4 роки тому +7

    7:27 It seems you still get POST when you refresh it?

    • @Ahmed-bb4yp
      @Ahmed-bb4yp 4 роки тому +3

      @@MuffinologyTrainer dude shut up and be grateful. You wanna pay $400 for a shitty udemy course? Go ahead. Nobody wants you to just complain and discredit the guy for his work.

    • @gadgetologist
      @gadgetologist 4 роки тому +2

      If you watch closely, you'll notice that Tim was explaining things correctly. His mistake was due to an honest error. When re-posting, he merely went too fast and didn't change the URL. Be nice. I commend him and anyone who gives of themselves. No need for the rudeness and crass comments/language.

    • @dorianvedel1910
      @dorianvedel1910 4 роки тому +3

      It seems the browser re-did the last action which was a POST. If Tim did tape enter in the url bar, he would have get a GET method.
      Don't know if I'm clear, english is not my native linguage... :/

    • @mauroconsolani2576
      @mauroconsolani2576 4 роки тому +1

      Hang, browsers repeat the last request they sent when they are asked to refresh a page. When the last request sent is a POST, when you refresh you get a POST again. A refresh would cause a duplicate form submission, which in almost all cases is not the desired action. For that reason, the browser asks for confirmation from the user (browser-pop-up message shown in the video).
      Many users do not understand this warning from the browser. Consequently, it is considered good practice for web applications to never leave a POST request as the last request sent by the browser. This is achieved by responding to POST requests with a redirect instead of a normal response.
      All these info comes from Miguel Grinberg's Flask Manual.
      I think your question was pretty clever and you didn't mean to "complain" or "discredit" Tim, whom by the way rocks at teaching. Have a good day!

  • @AviPars
    @AviPars 2 роки тому

    Can I have the server st a different domain than the front end ? How would i communicate? Via js request

  • @hamidja1537
    @hamidja1537 2 роки тому

    Thanks for sharing

  • @mariamkhanam4037
    @mariamkhanam4037 2 роки тому

    Hello Tim, Can we redirect to a site with post request? Suppose, "website/shortit" need "url" arg as post request. Now in "website" if i click on submit button. It will process the request and and if any conditions come true. It will redirect to "website/shortit" with post request. Every conditions have different arg.
    .
    .
    Can we redirect with post request??

  • @PeranMe
    @PeranMe 5 років тому +2

    Great stuff, as usual! Thanks for sharing this! Any plans on discussing security, like input sanitization etc?

  • @caliapster8720
    @caliapster8720 5 років тому +2

    ty *Tim sorry for saying your name wrong last time.
    I really appreciate these series.

  • @instylecasesinstylecases7239
    @instylecasesinstylecases7239 3 роки тому

    Hi! Awesome!
    What would you recommend for hosting of the simple site writing in python?

  • @skystep2
    @skystep2 3 роки тому

    Good video! I thinking how to get that data from input and just print it in console (other purpose, than generating page - for example just adding something to db), I tried but without success. Maybe is super-easy and I am just to tired ..

  • @geggiu99
    @geggiu99 3 роки тому

    heeey, i have a problem, i can't get the POST request on the terminal and if i type nm and click submit it doesnt do anything

  • @mohammadhassan5240
    @mohammadhassan5240 4 роки тому

    usefull and complete thank you

  • @KRKUN
    @KRKUN 3 роки тому +2

    Is this tutorial or a skill show?

  • @compton8301
    @compton8301 5 років тому +6

    Tim, could you please make a Udemy course. I love your fantastic teaching style. Udemy makes it easier for us "third world" student to afford quality content.
    Much appreciation from South Africa! ™️💯

  • @scholar-o9k
    @scholar-o9k 2 місяці тому

    the the case of post it isn't working .what do you think canbe the error

  • @rabi26
    @rabi26 4 роки тому

    Could Flask be used instead of PHP on a WAMP server to host my own website on my laptop just for experimentation but also have the server connected online so people can visit it? I understand the security risks.

  • @liveleakveteran8881
    @liveleakveteran8881 3 роки тому +1

    If you are getting the error 405 Method not allowed use the line methods = ["GET","POST"] on the @app.route wrapper seperated by a comma next to the subpage
    like so app.route("/login",methods=["GET","POST"])
    fixed the problem for me

  • @adhirajkar7396
    @adhirajkar7396 Рік тому

    But if we show the input value in the url then it is not safe ig, coz its a post request

  • @ThomasJr
    @ThomasJr 3 роки тому

    Ok, wow, after a lot of struggle I was able to make this work. Phew! But I was actually trying something way more advanced, to obtain the inputs from drop down lists and print them on the screen. Tim, is it possible to print the value in the same main page? Right now in order to display the values I am needing to go to a new Url, which doesn't make sense. I want to display the values in the same page as the drop down menus (there are various of them).

  • @rohandevaki4349
    @rohandevaki4349 4 роки тому

    Hey Tim can you make a tutorial for how to conect html,css,js with FLAK, and we should also be able to send and receive data in the json format, and I hope you use axios, or else you can use jquery and ajax.

  • @WrongIvoryGaming
    @WrongIvoryGaming 2 роки тому

    pls how can i retrieve more than one form data without using json .
    like lets say i want to retrieve item and quantity

  • @channelname437
    @channelname437 5 років тому

    Thanks for the video Tim. Can you recommend a book about web development?

  • @krishnapatel6821
    @krishnapatel6821 5 місяців тому

    why can't I use a get request when receiving data from the form?

  • @harshith_takkala
    @harshith_takkala 4 роки тому

    Awesome !!!

  • @Dante-ot8xg
    @Dante-ot8xg 3 роки тому

    I put / in the def home route and it gives me an error. Why is that?

  • @sanjuwa2677
    @sanjuwa2677 4 роки тому

    Thanks It worked

  • @minecraft4life688
    @minecraft4life688 4 роки тому +3

    7:09, after I login it comes with this error:werkzeug.routing.BuildError: Could not build url for endpoint 'harshi' with values ['usr']. Did you mean 'static' instead?
    plz help thanks

    • @safwanakhtar2528
      @safwanakhtar2528 4 роки тому +1

      try doing the tutorial again, it's great as its only a 10-minute video, I don't know if over the past week you've resolved that problem but I'm 9 minutes in and I have no problems

    • @minecraft4life688
      @minecraft4life688 4 роки тому +1

      @@safwanakhtar2528 Yes thank you I resolved it, it was a silly mistake

    • @tradingwithsujay
      @tradingwithsujay 4 роки тому +1

      @@minecraft4life688 bro what was the mistake I am getting same problem

    • @minecraft4life688
      @minecraft4life688 4 роки тому +1

      @@tradingwithsujay for the redirect I put redirect to the user page but I put just put user, you have to put user in quotation marks because that's the page

    • @minecraft4life688
      @minecraft4life688 4 роки тому

      Atleast that was the mistake for me

  • @michaelhajny1348
    @michaelhajny1348 4 роки тому

    I would like to ask to you if there is a chance that you will show up how to cooperate with sqlite and flask together. Thanks for watching this.

  • @arturoroche3782
    @arturoroche3782 3 роки тому

    07:34 Determine POST and GET in login function

  • @josephedomobi7701
    @josephedomobi7701 2 роки тому

    i do have a question sir ...the way these forms are been rendered are they safe from csrf hacks ...because you didn't use flask wtf and i heard it prevents such attacks..i hope you understand me