Mercurial > prosody-modules
comparison mod_rest/example/app.py @ 4248:f3fbfde9683d
mod_rest/example: Reorder things to match the disco#info feature order
Satisfies my OCD!
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sun, 15 Nov 2020 15:41:52 +0100 |
| parents | 53ae1df31950 |
| children |
comparison
equal
deleted
inserted
replaced
| 4247:1f93fa24611d | 4248:f3fbfde9683d |
|---|---|
| 29 if data["kind"] == "message" and "body" in data: | 29 if data["kind"] == "message" and "body" in data: |
| 30 # Reply to a message | 30 # Reply to a message |
| 31 return jsonify({"body": "Yes this is flask app"}) | 31 return jsonify({"body": "Yes this is flask app"}) |
| 32 | 32 |
| 33 elif data["kind"] == "iq" and data["type"] == "get": | 33 elif data["kind"] == "iq" and data["type"] == "get": |
| 34 if "ping" in data: | 34 if "disco" in data: |
| 35 # Respond to ping | |
| 36 return Response(status=204) | |
| 37 | |
| 38 elif "disco" in data: | |
| 39 # Return supported features | 35 # Return supported features |
| 40 return jsonify( | 36 return jsonify( |
| 41 { | 37 { |
| 42 "disco": { | 38 "disco": { |
| 43 "identities": [ | 39 "identities": [ |
| 65 | 61 |
| 66 elif "version" in data: | 62 elif "version" in data: |
| 67 # Version info | 63 # Version info |
| 68 return jsonify({"version": {"name": "app.py", "version": "0"}}) | 64 return jsonify({"version": {"name": "app.py", "version": "0"}}) |
| 69 | 65 |
| 66 elif "ping" in data: | |
| 67 # Respond to ping | |
| 68 return Response(status=204) | |
| 69 | |
| 70 return Response(status=501) | 70 return Response(status=501) |
| 71 | 71 |
| 72 | 72 |
| 73 if __name__ == "__main__": | 73 if __name__ == "__main__": |
| 74 app.run() | 74 app.run() |
