2

I'm writing an application that uses HTML pages as it's user interface - the user runs it on his computer and opens http://localhost:8080. After writing about a thousand lines of code implementing my own vision of MVC model, I noticed I'm pretty much trying to reinvent the wheel - RequestHandler import classes that implement do_POST and do_GET for a specified case, session handling... I've pretty much realized I'm doing it wrong.

I'd prefer to stick to the model that my Python script runs a HTTP server (most prefferably one from the standard library), because I like this architecture. The question is - is there some HTTPServer-like class that would give me an interface similar to CGI (parsing the GET URI, automatically loading the views and models) without giving me a lot of overhead? I'd prefer it to be as small and simple as possible, so if there's no standard library based solution, let it at least be pure Python.

1
  • 2
    Search for "Python micro web framework" - Flask and Bottle are good candidates Commented Dec 16, 2012 at 13:51

1 Answer 1

2

There is a CGI capable HTTP server already baked into python - that's probably the simplest place to start.

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

3 Comments

Doesn't it have problems with redirects?
Yes, but you should be able to handle that elegantly; for instance checking for a redirect (or exception) and redirecting to SimpleHTTPServer
Elegantly? That feels rather hacky.

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.