Let's consider example of YAML
formatted configuration file:
application: myapp
version: alpha-001
runtime: python27
api_version: 1
threadsafe: true
# url handlers
handlers:
- url: /
script: home.app
- url: /index\.html
script: home.app
- url: /stylesheets
static_dir: stylesheets
- url: /(.*\.(gif|png|jpg))
static_files: static/\1
upload: static/.*\.(gif|png|jpg)
- url: /admin/.*
script: admin.app
login: admin
- url: /.*
script: not_found.app
In [1]:
# print all urls
import yaml
import io
val = yaml.safe_load(io.open("example_config.yaml", "rt"))
print([entry["url"] for entry in val["handlers"]])
In AXON it will be formatted as:
application: "myapp"
version: "alpha-001"
runtime: "python27"
api_version: 1
threadsafe: true
# url handlers
handlers: [
{ url: "/"
script: "home.app" }
{ url: "/index\.html"
script: "home.app" }
{ url: "/stylesheets"
static_dir: "stylesheets" }
{ url: "/(.*\.(gif|png|jpg))"
static_files: "static/\1"
upload: "static/.*\.(gif|png|jpg)" }
{ url: "/admin/.*"
script: "admin.app"
login: "admin" }
{ url: "/.*"
script: "not_found.app" }
]
In [2]:
# print all urls
import axon
val = axon.load("example_config1.axon")
print([entry["url"] for entry in val["handlers"]])
With AXON
it can be also presented in the following form:
_
application: "myapp"
version: "alpha-001"
runtime: "python27"
api_version: 1
threadsafe: true
# url handlers
handlers
_
url: "/"
script: "home.app"
_
url: "/index\.html"
script: "home.app"
_
url: "/stylesheets"
static_dir: "stylesheets"
_
url: "/(.*\.(gif|png|jpg))"
static_files: "static\1"
upload: "static/.*\.(gif|png|jpg)"
_
url: "/admin/.*"
script: "admin.app"
login: "admin"
_
url: "/.*"
script: "not_found.app"
In [3]:
# print all urls
vals = axon.load("example_config2.axon")
print([entry.url for entry in vals[0].handlers])
Isn't configuration file in AXON
as readable as in YAML
?
In [ ]: