The ${package}/public/ directory is searched for static files before your controllers are run. Remove this file (${package}/public/index.html) and edit the routes in ${package}/webconfig.py like so:
m.connect('', controller='entry', action='view', id=10)Please Note: If this is your first time using Myghty, you should follow the 'Getting Started' below, then read the Myghty documents to become familiar with Myghty templates. Do this before removing this file (index.html).
You're now ready to start creating your own web application. Here's what a basic controller looks like to print out 'Hello World' and respond to http://localhost:8000/hello:
# ${package}/controllers/hello_controller.py # Note that the line above is the file you should create and put the following into... from application_controller import * class HelloController(ApplicationController): def index(self, m, **params): m.write('Hello World') hello = HelloController()
If you want to call a template and do something a little more complex, here's an example printing out some request information from a Myghty template.
# ${package}/templates/serverinfo.myt <p>Hi, here's the server environment: <br /> <% str(r.environ) %></p> <p> and here's the URL you called: <% url_for() %> </p>Then add this to your hello controller class:
def serverinfo(self, m, **params): m.subexec('/serverinfo.myt')You can now view the page at: http://localhost:8000/hello/serverinfo