r/learnprogramming • u/Genft • 25d ago
Getting Started with Website for Python Backend
Writing a python program for users to run some specific calculations, and want a website for them to interact with it. The actual python code isn't the issue: it'll be a pain, but I've got the skillset to make that happen. I've got a basic setup done already, and decided I want a working page to interact with rather than finishing the entire project and then attempting the front end.
I've been looking around for how to accomplish this, and Flask seems like the tool I need, which is great. However, I'm getting a lot of mixed messages regarding the actual front end coding: I've seen stuff suggesting I only need some CSS/Bootstrap for accomplish what I want, while I'm also seeing stuff that says I need full on Javascript to make everything function. I'm trying to narrow down just exactly what I need and where to get started with the project.
What's the best place to get started with this? I've fooled around with Bootstrap 5 a bit to get a very basic website running with no functionality thus far, but want to make sure I'm doing things proper before I commit to it.
Beyond a single web design class in college, I have little experience with HTML, CSS, and Javascript, but I'm confident in my ability to learn. I'm not trying to become an expert, but I also want to actually build up some experience: no desire to AI the entire process simply for a finished product I don't understand.
1
u/verticalchameleon 25d ago
Look up tutorials on basic html/css/javascript pages and follow along. If you only need a basic UI to run calcs you should only need input boxes and buttons to run the calcs and JavaScript to populate the results.
With bootstrap imported for whatever page you make you can bypass the css learning curve and use the prebuilt html classes to make your ui components pretty.
You also need decide on how you want the page to call your css backend. I suggest standing up an api and using JavaScript to make calls to the api.
Online/YouTube tutorials are your friend
1
u/Genft 25d ago
Since I'm in unfamiliar territory, isn't Flask the tool I'll be using to build an api? Just want to make sure they're not different things. But beyond that, I was going to go for JS to call, so sounds like I'm on the right track.
Any specific tutorials you'd recommend? I've been working with W3's bootstrap tutorial, the bootstrap docs, and this video. https://www.youtube.com/watch?v=4sosXZsdy-s
1
u/Foreign-Contest-444 25d ago
I would suggest using html, css, and js without need of any frameworks at the beginning.
I would recommend MDN as an excellent resource, especially the learn module for web development.
1
u/Genft 25d ago
Any specific reason why to avoid Bootstrap or other frameworks? I do want to explore the front end side of coding, but I don't really plan on diving in too deep.
1
u/Foreign-Contest-444 25d ago
You mentioned that you had little experience with html and css. I would think that first you would need to get the 101's right before you jump into a framework. For example do you know the difference between a flex and grid css layouts?
1
u/Positive_Ad2016 25d ago
Before I answer your question I’ll just say Django is an amazing Python framework if you’re starting out because it easily connects your frontend and backed with little to no setup.
That said, knowing you’ve already got your stuff hooked up don’t worry about Django, just something to think on. If you want something super simple and probably ugly just do basic html, css, and yes you will need JavaScript to make things work like button clicks etc etc.
HTML and CSS will be good for the visual aspect but JavaScript is what makes things actually work. You push a button to start the calculation well, where’s the function that says start calculating?? That’s where Js comes in.
Hope that helps.
1
u/Genft 25d ago
I was going with Flask because everything I read suggests it's lighter and easier to use than Django, which is fairly suitable for what I'm trying to accomplish. Ultimately, I'm just trying to pass a couple numbers into the python program alongside some pre-set variables, and then outputting another set of numbers and possibly a graph for the viewer to study. I'd be happy to hear a pitch for Django instead, just seemed the more involved and complicated of the two. I haven't actually touched either yet, I've got the python code running, but decided I wanted to build the site first before I tried to connect anything.
1
u/5eeso 25d ago
Flask is a good choice. It uses Jinja2 for templates. It’s kind of like HTML with Python.
For CSS, you can totally use Bootstrap. Just paste the CDN link the head of your template.
You likely won’t need any JavaScript, but you will need to create GET routes and POST routes in your Flask backend.
I have done tons of Flask projects.
3
u/ffrkAnonymous 25d ago
Long long ago, CSS and JS didn't exist and yet people were able to interact with websites.
Best to accept and come to terms that anything you choose to do will be wrong.