Forums

problem with APP_ROOT

Hi guys, I am dynamically generating a file which I am storing at APP_ROOT/folder/file...problem is when trying to load the same file in browser I get a 404 error because the browser appends APP_ROOT/folder/file to the domain..so instead of domain/folder/file I get domain/APP_ROOT/folder/file/ which is the same as APP_ROOT/APP_ROOT/folder/file/. I tried everything except opening the html file and rewriting the path(last resort).

Is there a Flask fix for this...?

Hi there,

I'm not quite sure I understand what's going on here. When you say "the browser appends APP_ROOT", what do you mean? Can you give a specific example of a file you want to be able to access, what its path on disk is, and what its url is?

Are you using our static files system, or something built into flask?

Hey Harry, I am using this code

bar.to_json('home/brandality1/myproject/static/folder/file', html_out=True, html_path='chart.html')

which produces this template

<html>  
<head>    
    <title>Vega Scaffold</title>
    <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
    <script src="http://d3js.org/topojson.v1.min.js"></script>
    <script src="http://d3js.org/d3.geo.projection.v0.min.js" charset="utf-8"></script>
    <script src="http://trifacta.github.com/vega/vega.js"></script>
</head>
<body>
    <div id="vis"></div>
</body>
<script type="text/javascript">
// parse a spec and create a visualization view
function parse(spec) {
  vg.parse.spec(spec, function(chart) { chart({el:"#vis"}).update(); });
}
parse("home/brandality1/myproject/static/folder/file"); # trouble is here
</script>
</html>

the browser tries to parse the file at domain.com/home/brandality1/myproject/static/folder/file instead of domain.com/static/folder/file....unless I write a function to generate the right browser path. I have no idea. I am new at this...

[edited by admin for formatting]

ah, ok. I guess that's some kind of bug in the bar.to_json() function. Where does it come from? Maybe they have some kind of mailing list or forums where they would know more about how it works?