Skip to content
Sign upLog in
← Back to Community

HTML submitting your <form> to a URL? Or Java

Profile icon
UltimatePython

Hi, does anyone know this? How to submit form data to a URL? Or in Java. Doesn't have to be an URL, it can be anything that stores real data in.

Answered by CodingElf66 [earned 5 cycles]
View Answer
Voters
Profile icon
UltimatePython
Comments
hotnewtop
Profile icon
CodingElf66

I suggest you use Flask server.

<form action="/submit" method="post"> <input type="text" name="name" placeholder="Name"> </form>

Then, in main.py, do:

@app.route('/submit', method=["GET","POST"]) def submit(): name = request.form.get("name") db[name] = value # doesn't matter, you saved the name onto db!
Profile icon
UltimatePython

@CodingElf66
Why are you commenting nearly a month later? Help appreciated, though.

Profile icon
CodingElf66

@UltimatePython
Scrolling through every Replit Ask post.

Profile icon
xfinnbar

Add the action attribute to specify a URL. For example, take this form:

<form action="/page"> <input type="text" name="a-text-input"> <input type="submit" value="Submit"> </form>

Will send the following request to this URL when Hello is passed to the text input:
your repl url/page?a-text-input=Hello

P.S. Java (server and desktop focused general purpose language) is not JavaScript (browser scripting language)

Profile icon
UltimatePython

@xfinnbar
Ok thank you!

Profile icon
UltimatePython

@xfinnbar
Then I'll mark it as answered!