forked from fabston/TradingView-Webhook-Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
26 lines (23 loc) · 727 Bytes
/
main.py
File metadata and controls
26 lines (23 loc) · 727 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import config as config
from flask import Flask, request, abort
from handler import send_buy_order, send_sell_order
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)
send_buy_order(data)
return '', 200
elif config.Sell_Alert in data:
print('Alert Received:', data)
send_sell_order(data)
return '', 200
else:
abort(400)
else:
abort(400)
if __name__ == '__main__':
from waitress import serve
serve(app, host='0.0.0.0', port=80)