3

I would like get the data from a basic html form

    <form method="send" action="/send">
    Name <input type="text"  name="name"/>
    <input type="submit" value="Send">
</form>

into a python file. Is that possible or not? I do not want to have to use CGI. thanks Josh

0

3 Answers 3

4

Whether you will need to battle with CGI, depends on your use case.

Python frameworks. like Flask, tend to offer their own litte web servers out-of-the-box. However, such servers are mostly meant for testing during the development phase. Integration into full blown web browsers usually is via CGI or FastCGI, and can offer advanced customization and scale up to huge loads.

But, depending on your target audience, a good "included" web server, like the one in web2py will do for you. For learning purposes, or in a closed network behind a firewall, such solutions are perfectly ok and you aviod the tech CGI stuff. Once your app is finished or the "included" web server will not suit your needs anymore, you can still deploy your app behind a "real" web server.

If you really like it the tough way, you may also consider to write your own web server from scratch ;)

Sign up to request clarification or add additional context in comments.

Comments

0

Python work on server side. Browser work on client side. They communicate via network. So it is imposible to do that without CGI ar any CGI-like method (FastCGI, PSGI, WSGU etc...). The best way for Python is WSGI. Getting started wsgi http://uwsgi-docs.readthedocs.org/en/latest/WSGIquickstart.html Process form example http://eddmann.com/posts/understanding-python-wsgi-with-examples/

2 Comments

Actually, it is possible to implement a simple HTTP server that serves HTML to a client's browser. In that case, there is absolutely no reason to use CGI.
I have write CGI-like - that mean FastCGI, PSGI, WSGU or any like this.
0

If I am understanding your question correctly you could use the selenium module. As an example, if you wanted to get the source code from Google, your code would be:

from selenium import webdriver
driver = webdriver.Chrome() # Or Firefox, or whatever browser you use
driver.get('https://google.com')
data = driver.page_source

The source code for Google is now stored in the data variable.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.