anonuser0428
anonuser0428

Reputation: 12343

How to Combine Html + CSS code with python function?

I have zero experience with website development but am working on a group project and am wondering whether it would be possible to create an interaction between a simple html/css website and my python function. Required functionality: I have to take in a simple string input from a text box in the website, pass it into my python function which gives me a single list of strings as output. This list of strings is then passed back to the website. I would just like a basic tutorial website to achieve this. Please do not give me a link to the CGI python website as I have already read it and would like a more basic and descriptive view as to how this is done. I would really appreciate your help.

Upvotes: 0

Views: 3763

Answers (2)

Derek Litz
Derek Litz

Reputation: 10897

First you will need to understand HTTP. It is a text based protocol.

I assume by "web site" you mean User-Agent, like FireFox.

Now, your talking about an input box, well this will mean that you've already handled an HTTP request for your content. In most web applications this would have been several requests (one for the dynamically generated application HTML, and more for the static css and js files).

CGI is the most basic way to programmatically inspect already parsed HTTP requests and create HTTP responses from objects you've set.

Now your application is simple enough where you can probably do all the HTTP parsing yourself to gain a basic understanding of what's going on, but you will still need to understand how to develop a server that can listen on a socket.

To avoid all that just find a Python application server that has already implemented all of the above and much more. There are many python application servers to choose from. Use one with a small learning curve for something as simple as above. Some are labeled as "micro-frameworks" in this genre.

Upvotes: 1

user2286078
user2286078

Reputation:

Have you considered creating an app on Google App Engine (https://developers.google.com/appengine/)? Their Handling Forms tutorial seems to describe your problem: https://developers.google.com/appengine/docs/python/gettingstartedpython27/handlingforms

Upvotes: 0

Related Questions