[英]Initiate Python Script on AWS from Wordpress
I have the following use case in which I need to run a Python script on a AWS hosted VM with information from a Wordpress site: 我有以下用例,其中我需要使用来自Wordpress站点的信息在AWS托管的VM上运行Python脚本:
1) User enters a number of parameters in a form: 1)用户以表格形式输入许多参数:
x = 3
y = 5
2) parameters are stored in the WP backend along with other user information from the WP backend database: 2)参数与WP后端数据库中的其他用户信息一起存储在WP后端中:
user = "John Doe"
3) as soon as all data is inputed, data is sent to Python server, which runs a very complex script (cannot be replicated in PHP) 3)一旦输入所有数据,数据就会发送到运行非常复杂的脚本的Python服务器(无法在PHP中复制)
def foo(x,y, user):
bar = x + y
print(user, " receives ", bar," as an answer.")
4) result of the script (bar) is then returned to WP and stored for further use 4)脚本的结果(栏)然后返回到WP并存储以备将来使用
Data security is also a big issue in this case, so secured connections are a must. 在这种情况下,数据安全性也是一个大问题,因此必须确保安全连接。
Is this even possible? 这有可能吗?
This is straight-forward enough to do - you need to develop a REST API endpoint in Python, running on your AWS instance and must be accessible from your wordpress site (with whatever security you need in place). 这很容易做到-您需要使用Python开发一个REST API端点,并在您的AWS实例上运行,并且必须可以从您的wordpress站点进行访问(无论您需要何种安全保护)。
Checkout Flask / Flask-restful for the back-end piece and then you'll need to update your wordpress site to make the API call to execute the function and return the result. 检出Flask / Flask-restful作为后端,然后您需要更新wordpress网站以进行API调用以执行功能并返回结果。
Don't know a lot about wordpress, but I would be surprised if it was not a straightforward task to make an API call from it to any arbitrary endpoint with just a bit of custom code. 对wordpress不太了解,但是如果要用一点自定义代码从其向任意端点进行API调用不是一项简单的任务,我会感到惊讶。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.