--- a/mod_rest/README.markdown Wed Jan 01 10:59:24 2020 +0100
+++ b/mod_rest/README.markdown Wed Jan 01 12:06:46 2020 +0100
@@ -113,6 +113,33 @@
The stanzas MUST NOT have an `xmlns` attribute, and the default/empty
namespace is treated as `jabber:client`.
+# Examples
+
+## Python / Flask
+
+Simple echo bot that responds to messages:
+
+```python
+from flask import Flask, Response, request
+import xml.etree.ElementTree as ET
+
+app = Flask('echobot')
+
+@app.before_request
+def parse():
+ request.stanza = ET.fromstring(request.data)
+
+@app.route('/', methods = ['POST'])
+def hello():
+ if request.stanza.tag == 'message':
+ return Response('<message><body>Yes this is bot</body></message>', content_type='application/xmpp+xml')
+
+ return Response(status = 501)
+
+if __name__ == '__main__':
+ app.run()
+```
+
# Compatibility
Requires Prosody trunk / 0.12