the basic question of the beginner (absolute)

65 views
Skip to first unread message

aliane abdelouahab

unread,
Jun 26, 2012, 9:44:33 AM6/26/12
to Tornado Web Server
hi
now that i've finished understanding some concept of web, i come to
practice, and my question is simple and basic for any beginner, but
there is no answer in the web;
how to make a simple page where a user click on 'add' and sees the
items there.
in basic python it's simple to make it with a dictionary, but how to
translate this to something between html and python (tornado in this
case).
am sorry if it's a big thing that am asking for, but this is the
problem that i always face: how to add a VISUAL dictionary item.
thank you in advance :)

aliane abdelouahab

unread,
Jun 26, 2012, 9:47:38 AM6/26/12
to Tornado Web Server
from the basic idea, it's something related to the database, so in the
database interface you can add/remove (restful in the case of nosql),
but when doing so, it's an administrator with a special URI, but what
about a user that want to add a thing, how to handle all this? am i
complicating thing?
i've no background in php, and all websites i've found it seems that
they're done using php. so can you please help me here.

Lorenzo Bolla

unread,
Jun 26, 2012, 10:26:16 AM6/26/12
to python-...@googlegroups.com
I understand that what you want is an html page, with a form (http://www.w3schools.com/html/html_forms.asp) to fill in, and a backend to reply to an "Add" action. Basically, something like this: http://www.javascript-coder.com/html-form/html-form-tutorial-p1.phtml.

The standard way (but by no means the only one) to implement such thing is to:
  1. Write an html page with a form
  2. Name the form somehow (for example: "myForm"), give it an action (for example: "/add") and a method (for example: "post")
  3. Populate the form with many "input" fields (named for example: "field1", "field2", etc.) and add a "submit" button
  4. In your webserver, implement a handler responding to "post" requests going to "/add"
  5. Inside your handler, you'll be able to access the fields of the forms using "self.get_argument('field1')", etc.
  6. Whatever the server replies will be show on the page. If you only want to update "portions" of the page, you should look at how to do "ajax" requests.
hth,
L.

aliane abdelouahab

unread,
Jun 26, 2012, 5:17:19 PM6/26/12
to Tornado Web Server
wow! that's an excellent tutorial, thank you!
sorry because i'm a beginner and it's really difficult to jump from
the world where they say: dictionnary in python is ... as an exemple
test['hello']= something, but when it come to apply this to html, it's
something else! :p
thank you again, i'll try to understand well that logic.

On 26 juin, 15:26, Lorenzo Bolla <lbo...@gmail.com> wrote:
> I understand that what you want is an html page, with a form (http://www.w3schools.com/html/html_forms.asp) to fill in, and a backend to
> reply to an "Add" action. Basically, something like this:http://www.javascript-coder.com/html-form/html-form-tutorial-p1.phtml.
>
> The standard way (but by no means the only one) to implement such thing is
> to:
>
>    1. Write an html page with a form
>    2. Name the form somehow (for example: "myForm"), give it an action (for
>    example: "/add") and a method (for example: "post")
>    3. Populate the form with many "input" fields (named for example:
>    "field1", "field2", etc.) and add a "submit" button
>    4. In your webserver, implement a handler responding to "post" requests
>    going to "/add"
>    5. Inside your handler, you'll be able to access the fields of the forms
>    using "self.get_argument('field1')", etc.
>    6. Whatever the server replies will be show on the page. If you only
>    want to update "portions" of the page, you should look at how to do "ajax"
>    requests.
>
> hth,
> L.
>
> On Tue, Jun 26, 2012 at 2:47 PM, aliane abdelouahab <alabdeloua...@gmail.com
Reply all
Reply to author
Forward
0 new messages