0

i am trying to show on my website current price from bittrex.com . I am using flask 3.6 and python 3.6 on pythonanywhere This is my flask.app code:

from flask import Flask, render_template, request
import requests



app = Flask(__name__)


@app.route('/')
def price():
     url='https://bittrex.com/api/v1.1/public/getmarketsummary?market=btc-nav'
     z=[]
     r = requests.get(url)
     x=r.json()
     e1=x['result'][0]['Ask']

     return render_template('index.html', price=e1)




if __name__ == '__main__':
    app.run(debug=True)

this is my index.html file:

<!DOCTYPE html>

<html>

<head>
    <title>Title</title>
</head>

<body>

Search: <input type="text" id="search_form_input"></input>

<div id="text"></div>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>

<script>
setInterval(function() {
    $.ajax({
      type: "POST",
      url: "/",

    })
      .done(function( price ) {
        $("#price-box").val(price)
      });
}, 1000 * 60);
</script>

</body>

</html>

i v got 500 Internal Server Error , so guess problem with connection to ajax src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js">

this is error log file :

[2017-11-01 11:15:25,093] ERROR in app: Exception on / [GET]
2017-11-01 11:15:25,107: Traceback (most recent call last):

raise TemplateNotFound(template)
2017-11-01 11:15:25,111: jinja2.exceptions.TemplateNotFound: index.html

how to solve this problem ? maybe there is more correct way to show dynamically changing data on my website ?

Flask on pythonanywhere uses the directory templates by default but iam trying this and nothing changed return render_template('index.html', price=e1 ,template_folder='/home/weblanss/crypto_compare/index.html')

egorkh
  • 456
  • 5
  • 22

0 Answers0