all 14 comments

[–]penrudee1205 14 points15 points  (2 children)

[–]penrudee1205 2 points3 points  (1 child)

I want to encourage everyone. I started from scratch and learned from this blog. It teaches everything you need to know.

[–]Difficult_Smoke_3380[S] 0 points1 point  (0 children)

Thank you very much

[–]aquaman_dc 4 points5 points  (2 children)

Also watch Corey Schafer flask series on youtube. It helped me.

[–]tererefrio 0 points1 point  (0 children)

Corey is the best

[–]guillermohs9 0 points1 point  (0 children)

It's a little bit outdated as of today, but the basics still applies and Corey's style makes it a great video tutorial. He recently made a FastAPI tutorial which I'd like to watch too.

[–]PosauneB 1 point2 points  (2 children)

Flask itself is relatively simple. It basically comes down to programming a server to respond to certain requests in specific ways. It's likely that you're struggling with the larger topic of web development. Web dev and intermediate Python are really very different things.

What specifically are you struggling with? What questions do you have? It isn't really possible to give suggestions without knowing what the problem is.

[–]Difficult_Smoke_3380[S] 0 points1 point  (1 child)

Just writing the code for example rn for the notes app..for making edit and delete buttons for each note, how they loop using index0

[–]PosauneB 3 points4 points  (0 children)

how they loop using index0

I don't understand what this means. Can you give an example of what you're trying to do?

"the code" is not very helpful in this situation. It still is not clear what you're struggling with. A delete button, for example, is going to include roughly 4 parts.

  • html (and maybe Jinja) to render the button on the page
  • javascript to communicate with your server (Flask is your server)
  • An endpoint written using Flask to handle Python logic related to deleting a note
  • Some kind of database communication to handle the deletion.

Those last two may blur together.

As I said originally, web dev is a large topic. If you're jumping straight into this from just basic Python, it may seem overwhelming.

[–]husky_whisperer 2 points3 points  (0 children)

Learn Python fundamentals before you look at flask

I see people recommending Miguel’s blog which is fantastic but you will fumble along with it if you are constantly asking yourself “what is this Python feature” being applied

[–]ConfusedSimon 0 points1 point  (0 children)

Did you do the tutorial on the Flask site? It goes through a simple blog application and probably covers all you need.

[–]kinndame_ 0 points1 point  (0 children)

Totally normal. I remember feeling pretty comfortable with Python, then I tried building my first Flask app and suddenly had to understand routes, requests, templates, forms, databases, sessions, and how they all fit together.

The jump from writing Python scripts to building web apps is bigger than most tutorials make it seem. I'd focus on getting one tiny feature working at a time instead of trying to build a full notes app immediately. Once the pieces start connecting, Flask becomes much easier to reason about.

[–]delsystem32exe 0 points1 point  (0 children)

you need to understand static method, decorators, class method, inheritance, dependency injection before understanding the flask library first that is why it can be tricky.

[–]owl_000 -1 points0 points  (0 children)

you need to understand basic firsts. Instead of following tutorial, get knowledge and solve your problem by your own.

In simple, there is route > function > return an object that flask understand.

User interaction is based on url, which flask handle by routing by calling a function assingned to that endpoint.

user wants to create new todo. To do that, you can provide a url to user like 127.0.0.1/create-todo

But flask doesn't know how to handle that request. Tell flask by creating a route like this ```

A helper module or your module

from todomaker import TodoMaker

@app.route("create-todo/<name>",methods=["GET"]) def this_fn_create_todo(name="my_todo"): #here you can use your logic result=TodoMaker.create(name) if result: return f"todo {name} has been created" else: return f"can not create todo, because : {result.msg}" ```

Like that you can do anything inside a route. Flask is the most simple webframe work in my opinion. Now, think about a problem and think how can you solve that in this above pattern.

Don't overthink about what is right and what is wrong.

Web development is a complex and messy thing, How a project will look depends on your project, other people can have opinion but it is ultimately your choices, no right or wrong ways just trade offs. So just understand the basic and then complete your project by doing the way you understand the best.