Ragnar
Ragnar

Reputation: 2690

HTML - Python How to access form elements?

Trying to build my own webmail client. I get a template for the web part which look like this

<form name="input" action="test2.py" methog="get" class="form">
    <input type="text" name="Username" placeholder="Username">
    <input type="password" name="Pass" placeholder="Password">
    <button type="submit" id="login-button">Login</button>
</form>

Would like to get the input on click on the button of Username && Pass via GET method to fill this bunch of code in python.

user = ???(Username)
pass = ???(Pass)

And print to a new empty html file the value of thoses var.

New to python so everything I try seem to fail.

Upvotes: 0

Views: 1945

Answers (2)

Shuvo Shaha
Shuvo Shaha

Reputation: 1

Write import request without quotes at the top of your python file. Now use request.inputForm['name'] without quotes to access form elements where name is the element name.

Upvotes: 0

cdonts
cdonts

Reputation: 9599

You should use method="post", it won't work with a GET method (however it is misspelled, you wrote "methog").

Upvotes: 1

Related Questions