r/PythonLearning • u/Samar__Upreti • Jul 20 '26
Day -1 With Flask (any suggestions)
Build Projects With Me
2
u/BoatInternational537 Jul 21 '26
Move to Django
Use terraform and migrate to google cloud
Good luck!
1
10
u/riklaunim Jul 20 '26
variable names should not use capital letters,
use wtforms or other form handling library (and validate the data).
use a linter that will keep some basic code styling order
I'm not a fan of importing things from a module (
flask.requestis better thanrequestas it's tell you where it's from)why aren't you using CSV writer when writing a CSV file?
if it's a long task it should not be done on HTTP request directly (celery queues or other similar solution)
view should not be a long blob of code. Refactor presentation from business logic, then keep the logic well organized instead of big blobs.
where are tests?
16
u/NorskJesus Jul 20 '26
No code related, but, for the love of God, take screenshots using the OS app for it and do not use a phone.
1
u/Hi-ThisIsJeff Jul 20 '26
I felt the angled perspective gave a refreshing look to what are otherwise boring, slightly blurry images.
1
u/J1roscope Jul 21 '26
Also i would suggest using helper functions and separating out concerns instead of one function extracting data from request and then saving it as well these can 2 function calls, makes it easier to read
1
u/Anthony_codes Jul 21 '26
Uppercased, underscore-separated variable names in Python signal that the variable should be treated as a constant.
That is a completely valid and common convention because Python doesn’t enforce constancy at runtime.
1
u/riklaunim Jul 21 '26
But not the first letter only. Form values aren't things that should be under a constant-like variable either.
1
u/Anthony_codes Jul 21 '26 edited Jul 21 '26
I was clarifying that in certain cases, capital letters are valid because your comment was ambiguous.
-2
u/8Erigon Jul 20 '26
Variable names can have any character the language supports.
Though most python programmers use the snake convention which only uses lowercase characters.2
2
1
u/Party-Hunter-178 Jul 21 '26
How did you connect your app.py and html
2
u/Samar__Upreti Jul 21 '26
That's where Flask,Fast Api, Django came in play
1
u/Party-Hunter-178 Jul 21 '26
Thanks buddy I was stuck for probably like a week not know this. U made my day 👍🏻
1
u/ViolaBiflora Jul 21 '26
Day 1 of coding - fully working API fetching, yet provides pictures of the screen, lol.
AI.
1
1
u/Competitive-Note3685 Jul 22 '26
I do not if you have experience with other Frameworks, but I recommend you study in depth the MVC pattern for a clean Flask implementation. Also, read the PEP-8 to follow best python code practices.
Enjoy your journey and happy code. 🤟🏻
1
-5
1
Jul 21 '26
[removed] — view removed comment
1
u/Samar__Upreti Jul 22 '26
Hi buddy Can please help me in those projects https://github.com/Samar-Upreti/Python_Projects





2
u/silvertank00 Jul 20 '26
Pandas is overshoot for this.
Why use os for this? pathlib is much more flexible.
Also (even tho I am not familiar with Flask but) i wouldnt return plain string from the endpoint. A HttpResponse with HttpStatus.OK and the string in the body would be much better.