-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added _very basic_ support for search queries, and
example2.py
to demo
- Loading branch information
Showing
2 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from chasha import Chasha, Directory | ||
|
||
app = Chasha() | ||
|
||
|
||
@app.route('/foo') | ||
def foo(): | ||
return """Test\r | ||
Data\r | ||
Check if multiline...\r | ||
Works\r\n""" | ||
|
||
|
||
@app.route('/bar') | ||
def bar(): | ||
d = Directory("/bar") | ||
d.add_child("This is an empty directory") | ||
d.add_child("it exists simply to illustrate & test nested directories") | ||
d.add_child("and further, it is just neat") | ||
return d | ||
|
||
|
||
@app.route('/blah/<bar:int>') | ||
def blah(bar): | ||
ret = """ | ||
bar is {0}\r | ||
descriptor is {1}\r | ||
search is {2}\r\n""".format(bar, app.request.descriptor, app.request.search) | ||
return ret | ||
|
||
|
||
@app.default() | ||
def default(): | ||
d = Directory("/") | ||
d.add_child("Dynamic routing example; /blah/ accepts an integer") | ||
d.add_child([0, "Foo bar industries", "/foo", "127.0.0.1", "7070"]) | ||
d.add_child("Some test info here...") | ||
d.add_child("Some more test info...") | ||
d.add_child(Directory("/bar", port=7070, name="FooBar Testing")) | ||
d.add_child([0, "Test blah 10", "/blah/10", "127.0.0.1", "7070"]) | ||
d.add_child([0, "Test blah 20", "/blah/20", "127.0.0.1", "7070"]) | ||
d.add_child([0, "Test blab 30", "/blah/30", "127.0.0.1", "7070"]) | ||
return d | ||
|
||
app.run() |