从Angular 2前端调用后端python脚本(Calling a back end python script from Angular 2 front end)

编程入门 行业动态 更新时间:2024-10-17 21:28:23
从Angular 2前端调用后端python脚本(Calling a back end python script from Angular 2 front end)

我在Angular 2中有一个带有提交按钮的网页(为简单起见)。 我想在点击此提交按钮时调用Python代码。 python代码用于执行一些机器学习算法并返回一些响应。

你能给我一些意见吗?

I have a web page in Angular 2 with a submit button(for simplicity). I want to call Python code when this submit button is hit. The python code is meant to perform some Machine Learning algorithm and return some response.

Can you please give me some inputs on this ?

最满意答案

Angular2 +项目生成的JS / HTML只是客户端代码。 我知道没有直接的方法来执行后端指令。 您将需要一个中间层,最有可能是API形式。 Angular2 +应用程序可以向此API发出请求,您的后端会处理它。

尝试直接从ng2应用程序访问数据库的概念相同:

在Angular 2中连接数据库

The produced JS/HTML from an Angular2+ project is client-side code only. I understand there is not a direct way to execute backend instructions. You will need a middle layer, most likely in an API form. The Angular2+ application can make a request to this API, and your backend handles it.

It is the same concept of trying to access a DB directly from an ng2 application:

Connect database in Angular 2

更多推荐

本文发布于:2023-04-29 02:59:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1334502.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:脚本   后端   python   Angular   script

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!