how to transfer data from webpage hosted by replit to python program

I want to know how I can take contact info from the webpage like the email, the comment the name from the forms that I created and put it into a text file in python. So I am not sure because I’m new how to send the information from the webpage to the python program? The other question that came up was to contact the server and to know what the server name is for the webpage that’s being hosted seems to be important about regarding this question?

Repl link:

code snippet

Hi @panagranit, to do this you’ll need some form of backend. If you’re using Python, then Flask is a very popular choice due to it being very easy to learn. Take a look here: Quickstart — Flask Documentation (2.2.x)


thanks, so explain the process a little more? the web page created in replit is being served by replit? and the web page has a simple input box of message, email, and name of person inquiring about something. I want the web page to sent to data to my python program in replit. this is in same directory? or not. What does Flask do here? store the information from the web page? where is the code that you suggested by flask go? in same directory of web page or not? etc I want to get list of all messages as text file in python.

That is a lot of questions. Python Flask allows your Python program to host a webpage. In the same folder as “” (your Flask program) should be a folder called “templates” in which you put your HTML files. There are Flask templates on Replit. Since Flask is a server hosting your webpage, it allows you to have Python code interact with HTML. I’m 99% sure it’s possible to send user input from HTML to Python, but I don’t know how. Try Googling it. As for your wish to make this into a text file, that is easy to do with Python; so, once your HTML input is properly connected to Flask, the rest is easy.

Basic usage of text file in Python:

file = open("file.txt", "w") # "w" opens it as write. Python can't read and write text files simultaneously
file.write(stuff) # Here, stuff can be a string or a variable.
file.close() # Don't leave the file open unless you need to
1 Like

Yeah, make a form tag in the HTML, and make it post to the server. You can use the request.form dictionary.

I was about to say that you should close the file to save resources, but you edited it, I think. Or I’m blind.


@joecooldoo I saw you typing and it made me remember to close the text file. So I edited it.

1 Like

Oh, okay.

OK so I’m getting the overall idea is that the webpage has a limited capacity to do anything except for presenting a picture or text. That it cannot store data as input or is very limited. I found out that I can send data to emails for a sense if you have input, I found some code for that, however essentially its functionality is limited so that’s the problem.

but anybody who uses this cell phone knows that data is transferred to algorithmic manipulation all the time, so there must be some code that is cut and paste to do this?

1 Like

I stumbled across this topic again. I was actually working on something like this recently. I got partway using some stuff I found on the internet. Please feel free to fork and play with my code. It takes data from a webpage and writes it to a text file in Python. I tried to make a more complex version and it failed. If you get something working using this would you please share? I’d appreciate it.
EDIT: I got more stuff working on this busted thing.

I hate form data so I do request.get_json(). :))