Compare commits

...
This repository has been archived on 2023-01-06. You can view files and clone it, but cannot push or open issues or pull requests.

2 Commits

Author SHA1 Message Date
Mohammad Osama Khan 79a439d8ed
Create a simple webhook for flask application 2022-12-22 15:18:07 +05:30
Mohammad Osama Khan 88a061a0ff
Add transifex 2022-12-14 13:03:48 +05:30
3 changed files with 39 additions and 0 deletions

15
flask_webhook/server.py Normal file
View File

@ -0,0 +1,15 @@
from flask import Flask, request, abort
app = Flask(__name__)
@app.route('/webhook', methods=['POST'])
def webhook():
if request.method == 'POST':
print(request.json)
return 'success', 200
else:
abort(400)
if __name__ == '__main__':
app.run()

10
flask_webhook/webhook.py Normal file
View File

@ -0,0 +1,10 @@
import requests
import json
webhook_url = 'http://127.0.0.1:5000/webhook'
data = { 'name': 'Request three',
'Channel URL': 'test url3' }
r = requests.post(webhook_url, data=json.dumps(data), headers={'Content-Type': 'application/json'})

14
transifex_demo.py Normal file
View File

@ -0,0 +1,14 @@
from transifex.native.daemon import daemon
from transifex.native import init, tx
from transifex.native.rendering import PseudoTranslationPolicy, SourceStringErrorPolicy
from transifex.native.parsing import SourceString
init(token='1/6e212800e39991406f0001245517708823f293b8', languages=['el', 'fr', 'en'], secret='1/47cc0fcea6d5f229a618ae0a20e2b60113738fe1')
# Add some strings to push
strings = [SourceString('My Addresses')]
response_content = tx.push_source_strings(strings)
print(response_content)
tx.fetch_translations()
el_translation = tx.translate('My Addresses', 'fr')
print(el_translation)