谷歌应用引擎定时任务发布?

2024-03-29 13:11:34 发布

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

根据https://developers.google.com/appengine/docs/python/config/cron,作业在指定的url上调用get。有没有办法将作业配置为调用post?在


Tags: httpscomconfigurldocsgetgoogle作业
2条回答

如果您担心访问此URL,则可以限制它:

You can prevent users from accessing URLs used by scheduled tasks by restricting access to administrator accounts. Scheduled tasks can access admin-only URLs. You can restrict a URL by adding login: admin to the handler configuration in app.yaml.

from Securing URLs for cron

使用cron作业来命中特定的url。从GET到url,运行一个脚本,然后通过任务队列将POST发送到另一个url:

try:
    taskqueue.Task(
       url="/some_url/",
       name=task_name,
       method="POST",
       params={
          "post_param_1": post_param_1,
          "post_param_2": post_param_2,
          "post_param_3": post_param_3,
          etc
       }
   ).add(queue_name="my-queue")
except:
    pass        #throws TombstonedTaskError if tombstoned name used.

相关问题 更多 >