Skip to content

Commit

Permalink
adding routes to fetch maps
Browse files Browse the repository at this point in the history
  • Loading branch information
fscottfoti committed Mar 27, 2014
1 parent 3cdf95f commit bedb5d8
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
32 changes: 32 additions & 0 deletions urbansim/server/urbansimd.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,38 @@ def resp():
return wrap_request(request, response, resp())


@route('/maps')
def list_maps():
def resp():
files = os.listdir(misc.maps_dir())
return files
return wrap_request(request, response, resp())


@route('/map/<mapname>', method="GET")
def read_config(mapname):
def resp():
c = open(os.path.join(misc.maps_dir(), mapname)).read()
return simplejson.loads(c)
return wrap_request(request, response, resp())


@route('/map/<mapname>', method="OPTIONS")
def ans_opt(mapname):
return {}


@route('/map/<mapname>', method="PUT")
def write_config(mapname):
json = request.json

def resp():
s = simplejson.dumps(json, indent=4)
print s
return open(os.path.join(misc.map_dir(), mapname), "w").write(s)
return wrap_request(request, response, resp())


@route('/datasets')
def list_datasets():
def resp():
Expand Down
4 changes: 4 additions & 0 deletions urbansim/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ def charts_dir():
return mkifnotexists("charts")


def maps_dir():
return mkifnotexists("maps")


def runs_dir():
return mkifnotexists("runs")

Expand Down

0 comments on commit bedb5d8

Please sign in to comment.