First, let's understand how Flask serves files:
public/myimage.jpg
(or use whatever name you wish, but keep this directory!);python3 server.py
) and point your browser to http://localhost:5000/public/myimage.jpg
, it should display your image.server.py
; start the web server, point your browser to http://localhost:5000/myimage2.jpg
– it won't work… why?
Now, we want to move the html
page from earlier tasks to be served by the Flask web server:
initial_design.html
to the templates/
directory (we're using the default Flask convention);server.py
to call render_template
(see official quickstart guide) and actually serve your HTML file.
render_template
symbol from the Flask library!
/google
endpoint which automatically redirects to your favorite (or not) search engine!