Answer the question
In order to leave comments, you need to log in
How to run python Flask script with crontab?
There is a Flask application, it is necessary to run the payment verification function for each unpaid order every five minutes. Payment is verified by the presence of a transaction with 3 confirmations through the Blockr.io API.
from app.client.models import Orders, Payments, db
import requests
import json
def check_btc(num, amount):
s = requests.get('http://btc.blockr.io/api/v1/address/txs/' + str(num))
transactions = json.loads(s.text)['data']['txs']
for trans in transactions:
if trans['amount'] == amount and trans['confirmations'] >= 3:
return True
def check_order():
orders = Orders.query.filter_by(status=1).all()
payment = Payments.query.filter_by(type=2).first()
for order in orders:
result = check_btc(payment.num, order.price_in_currency)
if result == True:
order.status = 2
db.session.commit()
Traceback (most recent call last):
File "app/admin/check.py", line 1, in <module>
from app.client.models import Orders, Payments, db
ImportError: No module named app.client.models
Answer the question
In order to leave comments, you need to log in
IMHO, cron simply does not find a way to it.
Try like this:
Well, that is, tell the crown that they say first go to this folder, and then run the script.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question