I'm currently self-teaching myself Python using a book called "Head First: Python (2nd Edition)" and so far it has been good, but I'm currently stuck in the early stages of building a simple webapp. The webapp allows one to enter in a phrase and letters and then outputs the intersection of both. Since a good portion of the book builds off of this, I can't move forward by skipping this. I've been trying to find an error, but to no avail.
All the code is provided by the book at: http://python.itcarlow.ie/ed2/ch05/webapp/
The file vsearch4web.py in the folder is the final version, so don't use that. This is where I am at instead with my vsearch4web.py folder:
from flask import Flask, render_template
from vsearch import search4letters
app = Flask(__name__)
@app.route('/')
def hello() -> str:
return 'Hello world from Flask!'
@app.route('/search4')
def do_search() -> str:
return str(search4letters('life, the universe, and everything','eiru,!'))
@app.route('/entry')
def entry_page() -> 'html':
return render_template('entry.html',the_title='Welcome to search4letters on the web!')
app.run()
I have set up the folder structure as instructed:
webapp folder --> vsearch4web.py static folder (subfolder of webapp) --> hf.css (from "static") templates folder (subfolder of webapp) --> base.html, entry.html and results.html (from "template")
The files in the static folder and templates folder are downloadable in the above URL provided in the book.
However, when I run vsearch4web.py, and I go to my browser and enter the loopback address (http://127.0.0.1:5000/entry), I get a "500 Internal Server Error".
Both http://127.0.0.1:5000/ and http://127.0.0.1:5000/search4 work however.
I've tried rechecking the code several times but I don't know what I am missing.
Can someone please help?
Thanks.
htmlis not a Python type - OneCricketeerapp.run(debug=True)but at a guess it cant find your templates folder, and or entry.html - Joran Beasley