Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/315.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python云函数之后的重定向_Python_Python 3.x_Forms_Google Cloud Platform_Google Cloud Functions - Fatal编程技术网

Python云函数之后的重定向

Python云函数之后的重定向,python,python-3.x,forms,google-cloud-platform,google-cloud-functions,Python,Python 3.x,Forms,Google Cloud Platform,Google Cloud Functions,我的HTML表单 action="https://us-central1-PROJECT_ID.cloudfunctions.net/FUNCTION_ID" 与 该链接向Python 3.7 Beta运行时中的Google云函数发送电子邮件地址字符串 该函数正确执行并与第三方API交互 函数运行后,将加载一个带有 OK 作为唯一的内容。从这里我想重定向回我的网站,但我不能退出,我想知道如何做到这一点。 我试过了 将urllib.request放在Python函数的末尾 执行XMLHttp

我的HTML表单

action="https://us-central1-PROJECT_ID.cloudfunctions.net/FUNCTION_ID"

该链接向Python 3.7 Beta运行时中的Google云函数发送电子邮件地址字符串

该函数正确执行并与第三方API交互

函数运行后,将加载一个带有

OK
作为唯一的内容。从这里我想重定向回我的网站,但我不能退出,我想知道如何做到这一点。 我试过了

  • 将urllib.request放在Python函数的末尾
  • 执行XMLHttpRequest
  • 改变

    target="_blank"
    


正确的方法是什么?

谷歌云函数在引擎盖下为您的端点提供服务,因此您只需在末尾返回一个:

from flask import redirect

def test(request):
    return redirect('https://google.com')

什么是“你的网站”?听起来您可能应该从后端调用该函数,而不是直接从浏览器调用。将表单更改为按钮,单击,向云函数url发出post请求。如果成功,请执行window.location=“yourpage”@DanielRoseman我在这个实例中使用Firebase主机,所以我不相信我真的有后端?我之所以使用云函数,是因为我想尝试为这个项目实现一个完整的无服务器实现。
target="_self"
from flask import redirect

def test(request):
    return redirect('https://google.com')