1
votes

I'm new to python and the bottlepy framework. I'm having a problem with static files. For some reason (I can't figure) it's not finding the data file.

In my template file I'm trying to access a data file via a JQUERY AJAX method but get the following error message: POST /static/jsonFile HTTP/1.1" 404 41

Here is my python script:

from bottle import route, template, request, error, debug, static_file,run, TEMPLATE_PATH, get

TEMPLATE_PATH.insert(0,'./templates/')

@route('/')
@route('/map')
@route('/mapfile')

def map_file():
   output = template('slippyMap')
   return output

@route('/data/')
   def data_points(filename):
   return static_file(filename, root='/home/www/htmldocs/bottleapp3/')  


And here is the ajax method in my template:

$(document).ready(function(){

$.ajax({
         url: 'static/jsonFile',
         type: "POST",
         dataType: 'json',
         cache: false,
         data: 'static/jsonFile',
         success:function(data){
         .
         .
         .

Any ideas what I'm doing wrong?

EDIT: I think the problem maybe due to the fact that I don't have (or need) a script for my URL parameter in the AJAX method. My question is how can I get AJAX to ignore the URL parameter and access the data file on the data parameter?

1
Update: Forgot the url parameter in the ajax methodChrisJ

1 Answers

0
votes

try the url "/data/jsonFile".

or modify your code like this:

@route('/static/')
def data_points(filename):
   return static_file (filename, root='/home/www/htmldocs/bottleapp3/')