Answer the question
In order to leave comments, you need to log in
How to respond to POST requests in Python?
I tried to respond to POST requests from VKontakte servers, because I needed to confirm the server address for the callback api and create a bot. I still can't figure out how to implement it.
Task:
To receive notifications, you need to confirm the server address. A POST request containing JSON will be sent to it:
{ "type": "confirmation", "group_id": 1111111 }
The string that the server should return: ddddd
Answer the question
In order to leave comments, you need to log in
import falcon
import json
class CResourse(object):
def on_post(self, req, res):
data = json.load(req.stream)
res.status = falcon.HTTP_200
res.body = 'ddd'
app = falcon.API()
app.add_route('/callback', CResourse())
Flask:
from flask import Flask
app = Flask(__name__)
@app.route('/', methods=['POST'])
def response():
return 'ddddd'
if __name__=='__main__':
app.run()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question