Newbie Question ... Add Python code to Home.html

53 views
Skip to first unread message

Sam Duncan

unread,
Apr 9, 2020, 9:42:00 PM4/9/20
to web.py

Embarrassed to ask a newbie question, but I'm stumped. I can see how these three files below interact, but I've not been about to add a simple python program to Home.html.

Do you just add the following to Home.html? I'm sure there are egregious Python errors below.

Thank you so much for getting me out of this sand pit.

$word = "JeffreySamuel"
$word = word.upper()

$for letter in word:
    <h2>(letter)</h2><br />

-----------------------------

Controller.py

import web

urls = (
    '/', 'home',
    '/register', 'register'
)

render = web.template.render("Views/Templates", base="MainLayout")
app = web.application(urls, globals())

# Classes/Routes

class home:
    def GET(self):
        return render.Home()

class register:
    def GET(self):
        return render.Register()

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

-----------------------------

MainLayout.html

$def with (page)

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Artist Files Directory</title>
    <link rel="stylesheet" href="static/css/swag.css" />
</head>

<body>
    <div id="menu">
    <ul>
        <li><a href="/">Home</a></li>
        <li><a href="/discover">Discover</a></li>
        <li><a href="/profile">Profile</a></li>
        <li><a href="/settings">Settings</a></li>
        <li><a href="/register">Register</a></li>
    </ul>
    </div>

    $:page

</body>

</html>

-----------------------------

Home.html

<h1>Testing</h1>

Anand Chitipothu

unread,
Apr 9, 2020, 9:58:36 PM4/9/20
to webpy
On Fri, Apr 10, 2020 at 7:12 AM Sam Duncan <samuel....@gmail.com> wrote:

Embarrassed to ask a newbie question, but I'm stumped. I can see how these three files below interact, but I've not been about to add a simple python program to Home.html.

Do you just add the following to Home.html? I'm sure there are egregious Python errors below.

Thank you so much for getting me out of this sand pit.

$word = "JeffreySamuel"
$word = word.upper()

$for letter in word:
    <h2>(letter)</h2><br />

It is a bit tricky to do the assignments. You need to have a space after $ for assignment. The following would work.

$ word = "JeffreySamuel"
$ word = word.upper()

$for letter in word:
    <h2>$letter</h2><br />
Reply all
Reply to author
Forward
0 new messages