a few examples
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/python3
|
||||
import cherrypy
|
||||
import config
|
||||
import json
|
||||
|
||||
static_dir = '/templates/' # Needs to have trailing and leading slash '/'
|
||||
|
||||
@@ -8,5 +8,37 @@ class wellcome(object):
|
||||
'''Base Index constructor and expose function'''
|
||||
@cherrypy.expose
|
||||
def index(self):
|
||||
result = '<h1>Wellcome</h1>'
|
||||
result = '''{
|
||||
"firstName": "John",
|
||||
"lastName": "Smith",
|
||||
"isAlive": true,
|
||||
"age": 27,
|
||||
"address": {
|
||||
"streetAddress": "21 2nd Street",
|
||||
"city": "New York",
|
||||
"state": "NY",
|
||||
"postalCode": "10021-3100"
|
||||
},
|
||||
"phoneNumbers": [
|
||||
{
|
||||
"type": "home",
|
||||
"number": "212 555-1234"
|
||||
},
|
||||
{
|
||||
"type": "office",
|
||||
"number": "646 555-4567"
|
||||
},
|
||||
{
|
||||
"type": "mobile",
|
||||
"number": "123 456-7890"
|
||||
}
|
||||
],
|
||||
"children": [],
|
||||
"spouse": null
|
||||
}'''
|
||||
return json.loads(result)
|
||||
|
||||
@cherrypy.expose
|
||||
def other(self):
|
||||
result = '<h1>Other</h1>'
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user