Comments (11)
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()
from jester.
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.
You should be able to use @
:
get "/":
echo(@"q") # -> "foo" for http://localhost:5000/?q=foo
from jester.
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.
Something like this? https://github.com/dom96/jester/blob/master/tests/alltest.nim#L65L79
from jester.
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.
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.
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.
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.
Understood. I think I can close this issue, thank you for the help :-)
from jester.
Np :)
from jester.
Related Issues (20)
- how to make exit procs work with --threads:on? HOT 2
- jester.nim(369, 24) Error: type mismatch: got <Request, utils.Settings> (0.5.0)
- double log output when using httpbeast HOT 7
- static files respond to non-GET http methods HOT 1
- No way to get raw query parameters
- Relative staticDir behavior changed
- Double log output on http requests HOT 1
- Jester crashes when async sleeping HOT 5
- development on windows (httpbeast) HOT 1
- finally block getting called twice? HOT 3
- Support binding on IPv6 address
- `std/cgi` will be moved to nimble packages
- Runtime SIGBUS: HOT 1
- how to use the setCookie fuction? HOT 1
- Docs: adding sections
- formData identical keys
- Bump tag to give new version through nimble HOT 2
- Revert PR #171 which auto decodes URL parameters HOT 6
- The jester.nimble file needs to be updated for v0.6.0 HOT 2
- Cannot serve dynamic web pages HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jester.