Example #1
0
#!/usr/bin/env python
# encoding: utf-8
import os, logging
from smisk.mvc import main
import controllers, models

if __name__ == '__main__':
  models.setup_all()
  models.create_all()
  main(
    appdir=os.path.dirname(os.path.dirname(__file__)),
    log_level=logging.DEBUG
  )
Example #2
0
from web.contrib.template import render_jinja
from models import Codigo, db_session, setup_all, metadata
import web


metadata.bind = "sqlite://"
setup_all(True)

urls = ("/", "index", "/paste", "paste", "/(\d+)", "mostrar")

render = render_jinja("../templates")


class index:
    def GET(self):
        valores = web.input(codigo_origem=None)
        id_codigo_origem = valores["codigo_origem"]
        if id_codigo_origem:
            return render.index(texto=Codigo.get_by(id=id_codigo_origem).texto)
        return render.index()


class paste:
    def POST(self):
        form = web.input(codigo={}, tipo={})
        novo_codigo = Codigo(texto=form["codigo"], tipo=form["tipo"])
        db_session.commit()
        raise web.seeother("/%d" % novo_codigo.id)


class mostrar: