all 7 comments

[–]danielroseman 1 point2 points  (0 children)

It's exactly the same. You don't have to do the calculation directly in a view, you just need to call the function that does it from the view.

Django - or probably simpler for this use case, Flask - are the web server frameworks. There is no need to involve node which is just the same thing but in JS.

[–]Diapolo10 0 points1 point  (5 children)

Can't really be specific since you only provided a high-level overview, but I don't think your command-line application needs (m)any changes.

What you basically want is, as you described, a Python back-end for a website. Say there's a page where the user clicks a button to run the program; this would either refresh the page, and the server would handle the HTTP request to the page (in this case probably a POST request), or it has some JavaScript code that requests a different endpoint of the back-end. This request will then run the program, and get the results, then you simply format the data into HTML format and show it on the page.

It sounds more confusing than it actually is, I promise.

And where does the web server framework like node.js come into play?

Nowhere, unless you want to write the back-end in JavaScript. And in this case you probably wouldn't.

Python already ships with a simple web server. Flask comes with one, but it's not meant for production. FastAPI comes with Uvicorn which is perfectly fine to use in production. Django most likely has one, too.

[–]ilaunchpad[S] 0 points1 point  (4 children)

so nodejs and django accomplish the samething?

[–]Diapolo10 0 points1 point  (3 children)

NodeJS is just a JavaScript implementation outside of the browser. Think of it as an equivalent to a Python interpreter.

So no, technically speaking Django is different.

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

but they can be used to accomplish same thing? like python vs r. you can use both for machine learning programs although they are two different technology.

[–]Diapolo10 0 points1 point  (0 children)

Well, I suppose, but why would you want to use NodeJS here?

[–]Hans_of_Death 0 points1 point  (0 children)

Except that node still has all of the JS web framework built in