Skip to content

artemmavrin/yesod-hello-world

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

yesod-hello-world

docs

This is a simple application built to learn the Yesod Haskell web framework.

Run Server

Start the server locally at http://localhost:3000 using

stack run

Request/response examples

Valid routes are defined at config/routes.yesodroutes. The default response type is JSON, but HTML is also supported by using the Accept content negotiation header field.

/ GET

  • Request:
    curl http://localhost:3000
    Response:
    {"greeting":"Hello, World!"}
  • Request:
    curl 'http://localhost:3000/?name=Artem'
    Response:
    {"greeting":"Hello, Artem!"}
  • Request:
    curl http://localhost:3000 -H 'Accept: text/html'
    Response:
    <!DOCTYPE html>
    <html><head><title></title></head><body>Hello, World!</body></html>
  • Request:
    curl 'http://localhost:3000/?name=Artem' -H 'Accept: text/html'
    Response:
    <!DOCTYPE html>
    <html><head><title></title></head><body>Hello, Artem!</body></html>

/ POST

  • Request:
    curl -X POST http://localhost:3000 -H 'Content-Type: application/json' -d '{"name":"Artem"}'
    Response:
    {"greeting":"Hello, Artem!"}
  • Request:
    curl -X POST http://localhost:3000 -H 'Content-Type: application/json' -d '{"name":"Artem"}' -H 'Accept: text/html'
    Response:
    <!DOCTYPE html>
    <html><head><title></title></head><body>Hello, Artem!</body></html>

/{name} GET

  • Request:
    curl 'http://localhost:3000/Artem'
    Response:
    {"greeting":"Hello, Artem!"}
  • Request:
    curl 'http://localhost:3000/Artem' -H 'Accept: text/html'
    Response:
    <!DOCTYPE html>
    <html><head><title></title></head><body>Hello, Artem!</body></html>

About

Simple application written in the Yesod web framework.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published