Permalink
Browse files

Replace index page with index action of status controller

  • Loading branch information...
1 parent 4532030 commit 0ac94d84ed130a99acb3007faae3dff747f34b86 @ebroder committed Jul 16, 2008
View
2 bluechips/config/routing.py
@@ -18,7 +18,7 @@ def make_map():
map.connect('error/:action/:id', controller='error')
# CUSTOM ROUTES HERE
-
+ map.connect('/', controller='status', action='index')
map.connect('/:controller')
map.connect('/:controller/', action='index')
map.connect('/:controller/:action')
View
13 bluechips/controllers/status.py
@@ -0,0 +1,13 @@
+"""
+Calculate the current state of the books
+"""
+
+import logging
+
+from bluechips.lib.base import *
+
+log = logging.getLogger(__name__)
+
+class StatusController(BaseController):
+ def index(self):
+ return 'Hello World'
View
108 bluechips/public/index.html
@@ -1,108 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
- "http://www.w3.org/TR/html4/loose.dtd">
-<html>
-<head>
- <title>Pylons Default Page</title>
- <style>
- body { background-color: #fff; color: #333; }
-
- body, p {
- font-family: verdana, arial, helvetica, sans-serif;
- font-size: 12px;
- line-height: 18px;
- }
- pre {
- background-color: #eee;
- padding: 10px;
- font-size: 11px;
- line-height: 13px;
- }
-
- a { color: #000; }
- a:visited { color: #666; }
- a:hover { color: #fff; background-color:#000; }
- </style>
-</head>
-<body>
-
-<h1>Welcome to your Pylons Web Application</h1>
-
-<h2>Weren't expecting to see this page?</h2>
-
-<p>The <tt>bluechips/public/</tt> directory is searched for static files
- <i>before</i> your controllers are run. Remove this file (<tt>bluechips/public/index.html</tt>)
- and edit the routes in <tt>bluechips/config/routing.py</tt> to point the
- <a href="/">root path</a> to a 'hello' controller we'll create below:
- <pre> map.connect('', controller='hello', action='index')</pre>
-</p>
-
-<h2>Getting Started</h2>
-<p>You're now ready to start creating your own web application. To create a 'hello' controller,
- run the following command in your project's root directory:
-<pre>
-BlueChips$ paster controller hello
-</pre>
-
- This generates the following the following code in <tt>bluechips/controllers/hello.py</tt>:
-<pre>
-import logging
-
-from bluechips.lib.base import *
-
-log = logging.getLogger(__name__)
-
-class HelloController(BaseController):
-
- def index(self):
- # Return a rendered template
- # return render('/some/template.mako)
- # or, Return a response
- return 'Hello World'
-</pre>
-</p>
-<p>This controller simply prints out 'Hello World' to the browser. Pylons' default routes
- automatically set up this controller to respond at the <a href="/hello">/hello</a> URL.
- With the additional route described above, this controller will also respond at the
- <a href="/">root path</a>.
-</p>
-
-<h3>Using a template</h3>
-<p>To call a template and do something a little more complex, this following example
- shows how to print out some request information from a
- <a href="http://www.makotemplates.org">Mako</a> template.
-</p>
-<p>Create a <tt>serverinfo.mako</tt> file in your project's <tt>bluechips/templates/</tt>
- directory with the following contents:
-</p>
-<pre>
-&lt;h2&gt;
-Server info for ${request.host}
-&lt;/h2&gt;
-
-&lt;p&gt;
-The URL you called: ${h.url_for()}
-&lt;/p&gt;
-
-&lt;p&gt;
-The name you set: ${c.name}
-&lt;/p&gt;
-
-&lt;p&gt;The WSGI environ:&lt;br /&gt;
-&lt;pre&gt;${c.pretty_environ}&lt;/pre&gt;
-&lt;/p&gt;
-</pre>
-
-Then add the following to your 'hello' controller class:
-<pre>
- def serverinfo(self):
- import cgi
- import pprint
- c.pretty_environ = cgi.escape(pprint.pformat(request.environ))
- c.name = 'The Black Knight'
- return render('/serverinfo.mako')
-</pre>
-
-You can now view the page at: <tt><a href="/hello/serverinfo">/hello/serverinfo</a></tt>
-</p>
-</body>
-</html>
View
7 bluechips/tests/functional/test_status.py
@@ -0,0 +1,7 @@
+from bluechips.tests import *
+
+class TestStatusController(TestController):
+
+ def test_index(self):
+ response = self.app.get(url_for(controller='status'))
+ # Test response...

0 comments on commit 0ac94d8

Please sign in to comment.