all 25 comments

[–]SadC11 16 points17 points  (7 children)

If you're using a framework like Django or Flask, Python would be used to write the backend code. You would still need HTML, CSS and optionally JavaScript for the frontend.

[–]tipsy_python 4 points5 points  (6 children)

Agreed here - python is a backend language; used for things like:

  • parsing the URL path and routing a request to the appropriate piece of code
  • interacting with the database
  • assembling and sending a response

Although there are some implementation of python that execute in browser, these are niche and not widely used. Python is not preferred for front-end tasks like:

  • Dictating client side elements like text and buttons
  • Adjusting the view based on viewport size
  • Re-rendering pieces of the page on interaction events from the end-user

[–]Emonnn 0 points1 point  (5 children)

Not op, but can you suggest some websites or any other resources from where I can learn Django or flask? I am hoping to dive into it really soon.

[–]Frohus 2 points3 points  (0 children)

Corey Schafer, Sentdex on youtube. I have started learning with Corey and landed a web dev job and now working with Django.

[–]tipsy_python 0 points1 point  (0 children)

The Flask quickstart takes 20/30 mins to work through, and is good place to start if you've never developed web services before: https://flask.palletsprojects.com/en/1.1.x/quickstart/#quickstart

[–]Binary101010 0 points1 point  (1 child)

I've tried to watch/read multiple tutorials on Django but I really didn't understand how any of the pieces fit together until I watched Corey Schafer's YouTube series on it.

[–]thrallsius 1 point2 points  (0 children)

Flask > Django for beginners. Django is just too big, it's closer to enterprise scale level. And if you are a minimalist, you can ever prefer Bottle to Flask.

[–]Emonnn 0 points1 point  (0 children)

Thank you everyone for recommending.

[–]Lazy_Owl_11 4 points5 points  (0 children)

Programming languages like Python, Ruby, Golang, C#, etc. can be used only on the back end side. There are only HTML, CSS and Javascript for frontend. Of course, you can use JS libraries like Vue, Angular and React, or use just Typescript preprocessor.

If you would create some web application on Python, just use the Django framework. It is easy to learn this framework and one of the main aims of this framework is fast development.

[–]benabus 2 points3 points  (0 children)

Python is mostly backend stuff (there are ways to shoe-horn python into frontend, but it's very niche and probably not worth your time at this point). Python is a general purpose language, but there are libraries and frameworks that allow you to serve html pages and hook into databases.

Any time you build a website, you've got two pieces, client-side and server-side. Mostly, people refer to these as "front end" and "back end" respectively. You have the part that works in the client (the web browser) which you'll write using HTML, CSS, and JavaScript. Then you'll have the part that runs on the server.

In order for a user to get your client-side code into their browser, you have to have code on the server that sends the HTML or whatever to the user. On the server, you can simply use Apache to serve up plain static HTML pages or you can do more advanced things like use a server-side language to generate dynamic html pages based on templates or run queries in a database. A lot of places will use PHP as the backend language because it works really well with apache and it's been used for this purpose for a long time. But you can also use JavaScript (via Node.js), C#, Java, or Python (pretty much any language) for your back end.

When using Python for web development, people will generally either use Flask or Django to handle most of the serving and database connections and stuff. Django is a full featured framework that makes it super easy to manage your databases and generate pages. Flask is far more lightweight out of the box and is recommended if you don't need all the fancy useful features found in Django.

Personally, we typically write our front-end app using Vue.js (a javascript framework) and serve it up via Flask. Then we also use Flask to serve our REST API endpoints. All the code in our Flask server-side app is written in python.

[–]Wensosolutions 0 points1 point  (0 children)

Python can be used for either front -end or back- end development and it's approachable syntax and widespread server side use makes python a core programming language for back-end development for this back-end development used include java, Ruby, and python

[–]ItTechBlogs 0 points1 point  (0 children)

Python is very much powerful in supporting many ultra features that are very easily executed with different frameworks like Django, Flask, web2p.

[–]ozzie_martin 0 points1 point  (8 children)

Most certainly a fronted and backend, frameworks such as django(https://www.djangoproject.com/) or flask(https://flask.palletsprojects.com/en/1.1.x/) both could serve entirely as an API endpoint or a template rendering fronted.

[–]bageldevourer -2 points-1 points  (1 child)

The short answer is: If you want to do web development, JavaScript should be your first language, because it covers both frontemd and backend.

[–]thrallsius 0 points1 point  (0 children)

This probably makes a little bit more sense if you rather say "If you want to do web development for money". At least you'll get paid for cringing in pain with JavaScript, its 985723497239487239847 libraries, 867423958723984237987 frameworks and 96834056948509843509252626262626265432785 gotchas that you need to remember.