I have python code I would like a html page to display for:
I get errors return render_template('index.html')
I have tried specifying the template folder but it doesnt work also.
my project directory:
/api
-- api.py
-- /templates
---- index.html
i am also running the server like: flask run -h 192.168.x.x -p 8080
jinja2.exceptions.TemplateNotFound: index.html
- - [29/Feb/2020 20:35:20] "GET / HTTP/1.1" 500 -
from flask import Flask, render_template
import RPi.GPIO as GPIO
from time import sleep
GPIO.setmode(GPIO.BOARD)
GPIO.setup(3, GPIO.OUT)
app = Flask("__main__")
pwm = GPIO.PWM(3, 50)
pwm.start(0)
@app.route('/')
def index():
return render_template('index.html')
@app.route('/switch/<val>')
def switch(val):
if val == "on":
SetAngle(0)
elif val == "off":
SetAngle(180)
return
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0')
def SetAngle(angle):
duty = angle / 18 + 2
GPIO.output(3, True)
pwm.ChangeDutyCycle(duty)
sleep(1)
GPIO.output(3, False)
pwm.ChangeDutyCycle(0)
app.config['EXPLAIN_TEMPLATE_LOADING'] = Trueto check where flask is looking for your templates. What does it say? - mrzo