# Examples

&#x20;Simple Blogger Clone using Oreoweb

```
App.py

from Oreoweb import App, Templates
from models import db, Post

app = Oreoweb()


@app.route("/")
 def index(req, resp):
    posts = Post.select()
    resp.html = templates.render("index.html", {"posts": posts})


@app.route("/posts/{slug}")
def post(req, resp, slug):
    post = Post.select().where(Post.slug == slug).get()
    resp.html = templates.render("post.html", {"post": post})



if __name__ == '__main__':
    db.connect()
    db.create_tables([Post])
    app.run()
```

```
models.py

from peewee import CharField, DateTimeField, Model, SqliteDatabase, TextField

db = SqliteDatabase("my_database.db")


class Post(Model):
    title = CharField(max_length=255)
    slug = CharField(max_length=255, unique=True)
    summary = TextField()
    body = TextField()
    author_name = CharField(max_length=255)
    created_at = DateTimeField()

    class Meta:
        database = db
```

```
index.html

<!DOCTYPE html>

<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Posts</title>
</head>
<body>
  <h1>Posts</h1>
  {% if posts %}
    <ul>
        {% for post in posts %}
          <li>
            <h3><a href="/posts/{{post.slug}}">{{ post.title }} by {{ post.author_name }}</a></h3>
            <h4>{{post.summary}}</h4>
            <hr>
          </li>
        {% endfor %}
    </ul>
  {% else %}
    <p>No posts yet!</p>
  {% endif %}
</body>
</html>
```

```
Post.html

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>{{post.title}}</title>
</head>
<body>

<h1>{{post.title}}</h1>
Author: {{ post.author_name }} <br>
Date: {{ post.created_at }}

<p>
  {{ post.body }}
</p>

</body>
</html>
```

##


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://harishsg99.gitbook.io/oreoweb-do/examples.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
