json - How to keep listening for a request at the same time process another request in python
问题描述
So, it'a little complicated.
What I am trying to do:
- Hosting an app on heroku and listening for webhooks sent by a messaging app (in JSON format) and saving them to a Database(SQLite3).
- Use that Database to generate ticket on zoho desk.
- If the ticket status is open I'll update the ticket with the new message otherwise I create a new ticket.
- Overall it includes two processes: Listening for webhooks and creating a ticket
My problem/worries:
- I am able to listen for the webhooks but the problem I am facing is that when I am creating a ticket how can the same script listen for webhooks or vice and versa.
- I have no idea how I can make these things so that while updating/creating a ticket I should be able to receive webhooks.
Sample code to listen to webhooks(JSON files sent via POST method).
from flask import Flask, request, Response
app = Flask(__name__)
@app.route('/webhook', methods=['POST'])
def respond():
print(request.json);
return Response(status=200)
解决方案
你的过程不是很清楚。根据你的说法
您收到一条消息(通过 webhook)
然后你去生成一张票
如果工单状态为打开,您将使用步骤 1 中的消息更新工单
评论-如果您在第 2 步中生成了工单,那么为什么此工单状态不会打开?新票应该是开放状态,对吧?
如果工单状态为未打开,您将创建一个新工单
评论-但您说您在第 2 步生成票证?
也许我误解了你输入的内容,但你能更清楚地说明你的过程吗?
推荐阅读
- spring-boot - 方法 POST 所需的请求参数不存在
- javascript - 在 nextjs 中使用谷歌标签管理器后出现意外的哈希码
- azure - 删除 Azure-DevOps 帐户
- google-chrome-extension - 在 Chrome 扩展的脚本标签中启用脚本
- dynamics-365 - 当焦点位于可编辑网格(视图)中的单元格上时如何将光标移动到下一个或上一个字符
- html - 如何使用 Tailwind CSS 创建多个主题?
- matlab - 在 Matlab 的曲线拟合工具中使用哪种类型的方程?
- react-native - 我需要帮助了解 Animated.diffClamp(value, min, max) 的预期用途
- google-cloud-platform - 来自邮递员的谷歌云函数调用返回谷歌登录身份验证检查
- numpy - 在执行聚类或不使用任何聚类算法之前在数据集中查找质心