我在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
更多推荐
发布评论