Giter VIP home page Giter VIP logo

Comments (11)

Xe avatar Xe commented on July 26, 2024
  post "/submit":
    try:
      var
        username = $(request.formData.mget "username").body
        url = $(request.formData.mget "url").body

      db.updateTweetsByUser(username, url)
      db.exec(sql"insert into users values (null, ?, ?)", username, url)
      db.exec(sql"insert into tweets values (null, 'twtxtlist', ?, ?)",
              $(getTime().getGMTime().timeinfoToTime().toSeconds()),
              "Added user @<" & username & " " & url & ">")

      redirect "/users/" & username & "/0"
    except: fail()

taken from here

from jester.

andreaferretti avatar andreaferretti commented on July 26, 2024

Nope, what I get in request.formData is an empty table. According to the README, formData is populated only for a content-type of multipart/form-data. The usual url encoded format does not seem to be supported

from jester.

dom96 avatar dom96 commented on July 26, 2024

You should be able to use @:

get "/":
  echo(@"q") # -> "foo" for http://localhost:5000/?q=foo

from jester.

andreaferretti avatar andreaferretti commented on July 26, 2024

I am not talking about querystring parameters in a GET request. I am talking about form parameters in a POST request. The actual thing that gets sent to the server when clicking submit on a HTML form

from jester.

dom96 avatar dom96 commented on July 26, 2024

Something like this? https://github.com/dom96/jester/blob/master/tests/alltest.nim#L65L79

from jester.

andreaferretti avatar andreaferretti commented on July 26, 2024

I just checked, and in fact form parameters can be retrieved via @"parameter-name". :-)

I think it would be useful to document this (by the way, I could not find a way to distinguish them from url or querystring parameters with the same name).

I am not sure what the example you linked is about. Are you testing it by opening in a browser? If so, I would expect it to fail to extract the form data

from jester.

dom96 avatar dom96 commented on July 26, 2024

I think it would be useful to document this

PRs welcome ;)

(by the way, I could not find a way to distinguish them from url or querystring parameters with the same name).

That may be a problem, but can't you simply rename one of those?

I am not sure what the example you linked is about. Are you testing it by opening in a browser? If so, I would expect it to fail to extract the form data

Not sure why you would expect it to fail, it's a simple form and when you submit it you are shown where the data is stored.

from jester.

andreaferretti avatar andreaferretti commented on July 26, 2024

Yeah, of course one can avoid the name clash. It is not an actual issue I have, just an observation.

The reason I expect it to fail is that when posting a form from the browser the content is url-encoded, and as far as I can tell request.formData is only populated for multipart forms

from jester.

dom96 avatar dom96 commented on July 26, 2024

The reason I expect it to fail is that when posting a form from the browser the content is url-encoded, and as far as I can tell request.formData is only populated for multipart forms

It's just an example so if formData is empty it will just display {}.

from jester.

andreaferretti avatar andreaferretti commented on July 26, 2024

Understood. I think I can close this issue, thank you for the help :-)

from jester.

dom96 avatar dom96 commented on July 26, 2024

Np :)

from jester.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.