greg mic wrote:write "Hello user" to localhost
First off, it's important to get the vocabulary right. You don't "write to localhost". You "write a response" or you "write to a page hosted at localhost". When we talk about localhost, we mean the machine the software is currently running on.
if localhost has no parameters, and write "Hello *name*" if localhost does have a name parameter.
Again, localhost is a machine. It doesn't have parameters. You mean "if the URL contains a name argument".
Sorry for being nitpicky, but if you don't use the correct terminology it's going to be hard for people to help you.
Anyway, yes you nailed the GET mapping. Now let's take a look at the POST mapping.
For the postmapping, I should write a code that posts the following text backwards to localhost if it has no text parameter: " Have a nice day" and if it does have a text parameter, then the text written in the text parameter should be posted backwards.
It's extremely unfortunate that the assignment immediately teaches you wrong things.
POST messages are used when you want to make a change to an application, such as saving data to a database. When the action doesn't make any changes to the application, but only transforms your input and then spits it out again, you would use a GET message.
This is not your fault. Just keep in mind that POST is not normally used for the kinds of tasks like the one in your assignment.
What have you tried? What are you stuck on? Do you know how to trigger a POST request?