TradingView-Webhook-Bot/main.py

32 wiersze
939 B
Python
Czysty Zwykły widok Historia

2020-07-04 07:38:38 +00:00
# ----------------------------------------------- #
# Plugin Name : TradingView-Webhook-Bot #
# Author Name : sixBit #
# File Name : main.py #
# ----------------------------------------------- #
2020-07-11 15:52:48 +00:00
import config
2020-04-21 14:29:00 +00:00
from flask import Flask, request, abort
2020-07-11 15:52:48 +00:00
from handler import *
2020-04-21 14:29:00 +00:00
app = Flask(__name__)
@app.route('/webhook', methods=['POST'])
def webhook():
if request.method == 'POST':
data = request.get_data(as_text=True)
if config.Buy_Alert in data:
print('Alert Received:', data)
2020-07-11 15:52:48 +00:00
send_alert(data)
2020-04-21 14:29:00 +00:00
return '', 200
elif config.Sell_Alert in data:
print('Alert Received:', data)
2020-07-11 15:52:48 +00:00
send_alert(data)
2020-04-21 14:29:00 +00:00
return '', 200
else:
abort(400)
else:
abort(400)
if __name__ == '__main__':
from waitress import serve
serve(app, host='0.0.0.0', port=80)