Please help with ex 51

In this exercise is part about creating a link in the index.html to hello_form.html I did this
image but whenever I click on the link after submitting it doesn’t take me back. I am asking for help with how to properly create a link. I would really appreciate it.
Bear with me I am new to this forum

Welcome to the forum!

The syntax you have used for the href tag is correct.

But I’m confuse to the code you’ve posted:

You seem to have created a Python method ‘with’ that takes ‘Greeting’ as an argument. This method includes the HTML head code and then an if statement. This is very unusual approach.

Why not write the HTML and then inject the Python code (logic) where it’s needed. This will set you up for the typical modelling where html page templates are just html files that have embedded Python logic.

Also what is the $ signed before python code? Is this a Windows thing? I thought python code in flask templates needed to be between {% code %}.

@gpkesley Thank you for responding. Yes, it is an HTML page with python like code as the book instructs to write but looking at what you have said I have gone back to revisit the code. the $signed before the code I think is what tells lpthw.web which parts in the HTML are python code. Not including it produces errors.
Yes I am using a windows computer. Thank you so much for replying. You have helped me find the solution. Saying that the href tag was correct helped me think maybe it’s the link itself so i instead of just making it shorter or longer like i was doing or checking for spelling errors. I changed it to localhost:8080 and it worked I was able to cycle through the pages.
Again you were of great help. I really appreciate it :smile: :smile:

Glad you cracked it. It reminds me I need to revisit python/web on Windows!

I think you said you fixed it, but take a look the href="" part of your link.

The href means what URL in the browser to visit. That isn’t really the file on your computer, even though it might eventually load that file. You though, put the whole file name for the local computer, so your browser really isn’t going to access it through the website.

The way to think about this is your server is running on something like:

http://localhost:3000/

And you told your browser to go to:

http://localhost:3000/C:\Users\user\project

The localhost:3000 part is like google.com, so it’s like telling your browser to load the file on your computer but at google.com. It doesn’t work.

Instead, you probably just need to go to this URL manually in your browser, then copy and paste it without the http://localhost:3000/ part in front. Try that.

1 Like

@zedshaw image
That’s the change on line 13 and I was able to cycle through the pages. Thank you. the explanation makes a lot of sense.
This forum is so exciting. I can’t believe the author just responded to my question. It’s made my day :dancer: :dancer: :dancer: :dancer:

1 Like

That works, and you can also change it to:

href="/hello"

The browser knows you mean “on this site” and you can remove the http://localhost:8080/ part.

Also, you can post your code easier by doing this:

[code]
# put your code here
[/code]

Then we can select it and paste back edits easier.

1 Like

Thank you. I didn’t know how to do that