So I am trying to update prices on products, without having to refresh. I wat it to update live, but I don't understand. I have read a bunch of threads, but haven't figured it out.
Here is my python code:
@app.route('/bprices', methods=['GET'])
def bPrices():
f = requests.get(
'https://api.hypixel.net/skyblock/bazaar?key=[can get you a key if needed]').json()
products = [
{
"id": product["product_id"],
"sell_price": product["sell_summary"][:1],
"buy_price": product["buy_summary"][:1],
"sell_volume": product["quick_status"]["sellVolume"],
"buy_volume": product["quick_status"]["buyVolume"],
}
for product in f["products"].values()
]
return jsonify(products=products)
And here is my HTML + js:
<table
id="myTable"
class="table table-striped table-bordered table-sm table-dark sortable"
cellspacing="0"
>
<thead>
<tr>
<th aria-label="Product Name" data-balloon-pos="up">Product</th>
<th aria-label="Product's buy price" data-balloon-pos="up">
Buy Price
</th>
<th aria-label="Product's sell price" data-balloon-pos="up">
Sell Price
</th>
<th aria-label="Product's buy volume" data-balloon-pos="up">
Buy Volume
</th>
<th aria-label="Product's sell volume" data-balloon-pos="up">
Sell Volume
</th>
<th>
Margin
</th>
</tr>
</thead>
<tbody>
<tr>
<td id="price"></td>
</tr>
</tbody>
</table>
</div>
<script>
$SCRIPT_ROOT = {{ request.script_root | tojson | safe }};
(function () {
$.getJSON(
$SCRIPT_ROOT + "/_stuff", // Your AJAX route here
function (data) {
$("#price").text(data.products)
}
);
setTimeout(arguments.callee, 10000);
})();
</script>
currently, it is only displaying a JSON file of the data I want to access, most likely because of the "jsonify".
