Esempio n. 1
0
 def POST(self):
     ObjectWeb.header("Content-Type", "text/html")
     frm = myform()
     if not frm.validates():
         return "FAILED"
     else:
         return str(frm.email) + " " + str(frm.password)
Esempio n. 2
0
 def POST(self):
     ObjectWeb.header("Content-Type","text/html")
     frm = myform()
     if not frm.validates():
         return "FAILED"
     else:
         return str(frm.email) + " " + str(frm.password)
Esempio n. 3
0
 def POST(self):
     cookies = ObjectWeb.cookies()
     if not cookies:
         ObjectWeb.status("404 Not Found")
         return ""
     else:
         ObjectWeb.status("200 OK")
         return cookies.get("CookieName", "")
Esempio n. 4
0
 def GET(self, name):
     ObjectWeb.header("Content-Type", "text/plain")
     
     age = ObjectWeb.get("age", None)
     
     if age:
         return "Hello "+str(name)+", you are "+str(age)+" years old."
     else:
         return "Hello "+str(name)+"!"
Esempio n. 5
0
    def GET(self, name):
        ObjectWeb.header("Content-Type", "text/plain")

        age = ObjectWeb.get("age", None)

        if age:
            return "Hello " + str(name) + ", you are " + str(
                age) + " years old."
        else:
            return "Hello " + str(name) + "!"
Esempio n. 6
0
    def POST(self):
        ObjectWeb.header("Content-Type", "text/html")
        form = NewPostForm()

        if form.validates():
            blogrec.set_post(
                blogrec.BlogPost(str(form.title), str(form.content)))
            ObjectWeb.seeother("/")
            return ""
        else:
            return blogrec.display(form.render())
Esempio n. 7
0
 def POST(self):
     ObjectWeb.header("Content-Type", "text/html")
     form = NewPostForm()
     
     if form.validates():
         blogrec.set_post(
             blogrec.BlogPost(str(form.title), str(form.content))
         )
         ObjectWeb.seeother("/")
         return ""
     else:
         return blogrec.display(form.render())
Esempio n. 8
0
    def GET(self):
        ObjectWeb.header("Content-Type", "text/html")

        posts = blogrec.get_posts()

        if posts:
            content = ""
            for post in posts:
                content += "<div class='post' style='border: 1px solid #000;'>"
                content += "<h3>" + str(post.title) + "</h3>"
                content += "<section>%s</section>" % post.content
                content += "</div>"
        else:
            content = "<div>There are no posts.</div>"

        return blogrec.display(content)
Esempio n. 9
0
    def GET(self):
        ObjectWeb.header("Content-Type", "text/html")
        
        posts = blogrec.get_posts()

        if posts:
            content = ""
            for post in posts:
                content += "<div class='post' style='border: 1px solid #000;'>"
                content += "<h3>"+str(post.title)+"</h3>"
                content += "<section>%s</section>" % post.content
                content += "</div>"
        else:
            content = "<div>There are no posts.</div>"
                
        return blogrec.display(content)
Esempio n. 10
0
    def GET(self):
        # ObjectWeb.status("200 OK")
        ObjectWeb.header("Content-Type", "text/plain")

        return "Hello World!"
Esempio n. 11
0
    def GET(self, name):
        ObjectWeb.header("Content-Type", "text/plain")

        age = ObjectWeb.get("age", None)

        if age:
            return "Hello " + str(name) + ", you are " + str(
                age) + " years old."
        else:
            return "Hello " + str(name) + "!"


class E404Page(object):
    def GET(self):
        ObjectWeb.status("404 Not Found")
        ObjectWeb.header("Content-Type", "text/plain")

        return "404 Not Found"


app = ObjectWeb.Application({
    "/": MainPage,
    "/([a-zA-Z0-9_]+)": NamePage,
    "HTTP-404": E404Page,
})

if __name__ == "__main__":
    app.run("localhost", 8080)
else:
    application = app.getwsgi()
Esempio n. 12
0
 def GET(self):
     ObjectWeb.status("200 OK")
     return "PASS"
Esempio n. 13
0
 def GET(self):
     ObjectWeb.status("200 OK")
     ObjectWeb.setcookie("CookieName", "CookieValue")
     return ""
Esempio n. 14
0
 def GET(self):
     ObjectWeb.header("Content-Type", "text/plain")
     ObjectWeb.header("X-Powered-By", "ObjectWeb/2.0")
     return str(ObjectWeb.context)
Esempio n. 15
0
    def GET(self):
        ObjectWeb.header("Content-Type", "text/html")

        form = NewPostForm()
        return blogrec.display(form.render())
Esempio n. 16
0
 def POST(self):
     ObjectWeb.status("200 OK")
     return "REDIRECT PASS"
Esempio n. 17
0
 def GET(self):
     ObjectWeb.header("Content-Type", "text/html")
     frm = myform()
     return frm.render()
Esempio n. 18
0
 def GET (self):
     ObjectWeb.header("Content-Type","text/html")
     frm = myform()
     return frm.render()
Esempio n. 19
0
 def GET(self):
     ObjectWeb.header("Content-Type", "text/html")
     
     form = NewPostForm()
     return blogrec.display(form.render())
Esempio n. 20
0
 def GET(self):
     ObjectWeb.status("404 Not Found")
     ObjectWeb.header("Content-Type", "text/plain")
     
     return "404 Not Found"
Esempio n. 21
0
        else:
            content = "<div>There are no posts.</div>"

        return blogrec.display(content)


class NewPage(object):
    def GET(self):
        ObjectWeb.header("Content-Type", "text/html")

        form = NewPostForm()
        return blogrec.display(form.render())

    def POST(self):
        ObjectWeb.header("Content-Type", "text/html")
        form = NewPostForm()

        if form.validates():
            blogrec.set_post(
                blogrec.BlogPost(str(form.title), str(form.content)))
            ObjectWeb.seeother("/")
            return ""
        else:
            return blogrec.display(form.render())


ObjectWeb.Application({
    "/": MainPage,
    "/new": NewPage,
}).run(port=8080)
Esempio n. 22
0
 def GET(self):
     ObjectWeb.seeother("/")
Esempio n. 23
0
    def GET(self):
        ObjectWeb.status("404 Not Found")
        ObjectWeb.header("Content-Type", "text/plain")

        return "404 Not Found"
Esempio n. 24
0
 def GET(self):
     # ObjectWeb.status("200 OK")
     ObjectWeb.header("Content-Type", "text/plain")
     
     return "Hello World!"
Esempio n. 25
0
class EnvHandler(object):
    def GET(self):
        ObjectWeb.header("Content-Type", "text/plain")
        ObjectWeb.header("X-Powered-By", "ObjectWeb/2.0")
        return str(ObjectWeb.context)


class CookieRelay(object):
    def GET(self):
        ObjectWeb.status("200 OK")
        ObjectWeb.setcookie("CookieName", "CookieValue")
        return ""

    def POST(self):
        cookies = ObjectWeb.cookies()
        if not cookies:
            ObjectWeb.status("404 Not Found")
            return ""
        else:
            ObjectWeb.status("200 OK")
            return cookies.get("CookieName", "")


app = ObjectWeb.Application({
    "/": MainPage,
    "/redirect": RedirectHandler,
    "/env": EnvHandler,
    "/cookie": CookieRelay,
}).run(port=8080)
Esempio n. 26
0
myform = forms.Form(
    forms.Textbox("email", label="Email"),
    forms.Password("password", label="Password"),
    forms.Password("password2", label="Confirm Password"),
    forms.Submit("login", value="Login"),
    validators=[forms.Validator("Email must be a valid email", valid_email),
                forms.Validator("Passwords must match.", passmatch)]
)


class MainPage(object):
    
    def GET(self):
        ObjectWeb.header("Content-Type", "text/html")
        frm = myform()
        return frm.render()
    
    def POST(self):
        ObjectWeb.header("Content-Type", "text/html")
        frm = myform()
        if not frm.validates():
            return "FAILED"
        else:
            return str(frm.email) + " " + str(frm.password)


ObjectWeb.Application({
    "/": MainPage,
}, debug=True).run(port=8080)