DeChinees
DeChinees

Reputation: 293

Options for building a python web based application

I am building a simple Python web application and I want it to run stand alone like SABNZBD or Couch Patato. These applications are self contained web applications. What do these products use to serve up the web interface?

The application im building will do a lookup of images albums (folders) and when selected, present it a slide show kind of way. All information is in a XML file, so no database needed. My goal is to make the application as self contained as possible.

I have looked at Django and it looks a bit daunting and overkill for my application. What are my other options?

Upvotes: 4

Views: 1759

Answers (5)

deStrangis
deStrangis

Reputation: 1930

You can try something simpler, like Bottle, which is just one python file and gives you most of the web handling without unnecessary sophistication:

from bottle import route, run, template

@route('/hello/<name>')
def index(name='World'):
    return template('<b>Hello {{name}}</b>!', name=name)

run(host='localhost', port=8080)

Upvotes: 3

Alireza Sanaee
Alireza Sanaee

Reputation: 475

why don't you use flask in python ?

take a look at this http://flask.pocoo.org/

from flask import Flask
app = Flask(__name__)

@app.route("/")
def hello():
    return "Hello World!"

if __name__ == "__main__":
    app.run()

Upvotes: 11

MrD
MrD

Reputation: 2455

There are many options and they're all very easy to pick up in a couple of days. Which one you choose is completely up to you.

Here are a few worth mentioning:

Tornado: a Python web framework and asynchronous networking library, originally developed at FriendFeed.

import tornado.ioloop
import tornado.web

class MainHandler(tornado.web.RequestHandler):
    def get(self):
        self.write("Hello, world")

application = tornado.web.Application([
    (r"/", MainHandler),
])

if __name__ == "__main__":
    application.listen(8888)
    tornado.ioloop.IOLoop.instance().start()



Bottle: a fast, simple and lightweight WSGI micro web-framework for Python. It is distributed as a single file module and has no dependencies other than the Python Standard Library.

from bottle import route, run, template

@route('/hello/<name>')
def index(name='World'):
    return template('<b>Hello {{name}}</b>!', name=name)

run(host='localhost', port=8080)



CherryPy: A Minimalist Python Web Framework

import cherrypy
class HelloWorld(object):
    def index(self):
        return "Hello World!"
    index.exposed = True

cherrypy.quickstart(HelloWorld())



Flask: Flask is a microframework for Python based on Werkzeug, Jinja 2 and good intentions.

from flask import Flask
app = Flask(__name__)

@app.route("/")
def hello():
    return "Hello World!"

if __name__ == "__main__":
    app.run()



web.py: is a web framework for Python that is as simple as it is powerful.

import web

urls = (
    '/(.*)', 'hello'
)
app = web.application(urls, globals())

class hello:        
    def GET(self, name):
        if not name: 
            name = 'World'
        return 'Hello, ' + name + '!'

if __name__ == "__main__":
    app.run()

Upvotes: 10

pylover
pylover

Reputation: 8075

Checkout the Cherrypy:

import cherrypy
class HelloWorld(object):
    @cherrypy.expose()
    def index(self):
        return "Hello World!"
cherrypy.quickstart(HelloWorld())

This is so simple and powerful.I using it for 3 years in my all webapplications.

Upvotes: 2

thefourtheye
thefourtheye

Reputation: 239653

You might want to look at web.py. Here is the Hello World example

import web

urls = (
    '/', 'index'
)

class index:
    def GET(self):
        return "Hello, world!"

if __name__ == "__main__":
    app = web.application(urls, globals())
    app.run()

Upvotes: 2

Related Questions