""" """ from untwisted.plugins.rapidserv import RapidServ, send_response, Response, core, xmap, build, make, HttpServer, InvalidRequest import shelve DB_FILENAME = 'DB' DB = shelve.open(make(__file__, DB_FILENAME)) render = build(__file__, 'templates', 'view.jinja') class ImageUpload(object): HttpServer.MAX_SIZE = 1024 * 5024 def __init__(self, con): xmap(con, 'GET /', self.send_base) xmap(con, 'POST /add_image', self.add_image) xmap(con, 'GET /load_index', self.load_index) def send_base(self, con, header, fd, data, version): response = Response() response.set_response('HTTP/1.1 200 OK') HTML = render('view.jinja', posts = DB.iterkeys()) response.add_data(HTML) send_response(con, response) def load_index(self, con, header, fd, data, version): index = data['index'][0]
""" Description: This file implements a simple quote system using jinja2 template system. Usage: python app.py '0.0.0.0' 1025 """ from untwisted.plugins.rapidserv import RapidServ, send_response, Response, Locate, DebugGet, core, xmap, build, make import shelve DB_FILENAME = 'DB' DB = shelve.open(make(__file__, DB_FILENAME)) render = build(__file__, 'templates', 'show.jinja', 'view.jinja') class QuoteHandle(object): MAX_LENGTH = 30 def __init__(self, con): # Used to map a handle to a route. xmap(con, 'GET /', self.send_base) xmap(con, 'GET /load_index', self.load_index) xmap(con, 'GET /add_quote', self.add_quote) def send_base(self, con, header, fd, data, version): # The http response. response = Response() response.set_response('HTTP/1.1 200 OK') HTML = render('show.jinja', posts=DB.iteritems())
""" """ from untwisted.plugins.rapidserv import RapidServ, send_response, Response, core, xmap, build, make, HttpServer, InvalidRequest import shelve DB_FILENAME = 'DB' DB = shelve.open(make(__file__, DB_FILENAME)) render = build(__file__, 'templates', 'view.jinja') class ImageUpload(object): HttpServer.MAX_SIZE = 1024 * 5024 def __init__(self, con): xmap(con, 'GET /', self.send_base) xmap(con, 'POST /add_image', self.add_image) xmap(con, 'GET /load_index', self.load_index) def send_base(self, con, header, fd, data, version): response = Response() response.set_response('HTTP/1.1 200 OK') HTML = render('view.jinja', posts=DB.iterkeys()) response.add_data(HTML) send_response(con, response) def load_index(self, con, header, fd, data, version): index = data['index'][0]