如何使PHP重定向从运行aws服务的python函数生成的链接

2024-04-16 05:58:18 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用aws booto3和python生成quicksite链接。现在我想在单击html按钮时重定向到该链接。我在前端使用php和html。。我还在xampapachee服务器上运行代码

这是我的python代码:

import boto3
def linker():    
    client = boto3.client('quicksight', aws_access_key_id='   ',aws_secret_access_key='abc', region_name='us-east-2')
p= client.get_dashboard_embed_url(AwsAccountId="123", DashboardId="7d5163cf-801c-6666-ba2d-231d3b2ba1b5", IdentityType="IAM", SessionLifetimeInMinutes=100, ResetDisabled=True, UndoRedoDisabled=True)
return p['EmbedUrl']

这是redirect.php:

<?php
    $result = exec( "python abc.py" );

    if(isset($_POST['submit'])){  
       header("Location: $result");
    }

 ?>

这是html文件

<form action=redirect.php; ?> id="#form" method="post" name="#form">
<input id='btn' name="submit" type='submit' value='Submit'>
<?php include "redirect.php"; ?>

Tags: key代码nameformclientawsidaccess