Note that there are some explanatory texts on larger screens.

plurals
  1. POFlask : How to serve static files from under the template directory?
    primarykey
    data
    text
    <p>i use Flask and want to change my assets folder directory.Here's my folder structure:</p> <pre><code>/python /static /js /img /font /css /templates /default /css /js /img /venv app.py </code></pre> <p>I want to move all the folders under static folder <code>(js,css,font,img)</code> under to the folder <code>default</code>. But when i do this my css files and the others(<code>js etc.)</code> can not be loaded the page.Should i set a property to my application? I also tried this one:</p> <pre><code>app = Flask(__name__,static_path="/templates/default") </code></pre> <p>But could not make it.Is there another way to do this?Thanks a lot.</p> <p><strong>Update:</strong> When i remove the leading slash in the line above (<code>static_path="templates/default"</code>) got this error <code>ValueError: urls must start with a leading slash </code> with the traceback:</p> <pre><code>Traceback (most recent call last): File "app.py", line 17, in &lt;module&gt; app = Flask(__name__,static_path="templates/default") File "/Users/ozcan/Library/Python/2.7/lib/python/site-packages/flask/app.py", line 481, in __init__ view_func=self.send_static_file) File "/Users/ozcan/Library/Python/2.7/lib/python/site-packages/flask/app.py", line 63, in wrapper_func return f(self, *args, **kwargs) File "/Users/ozcan/Library/Python/2.7/lib/python/site-packages/flask/app.py", line 943, in add_url_rule rule = self.url_rule_class(rule, methods=methods, **options) File "/Users/ozcan/Library/Python/2.7/lib/python/site-packages/werkzeug/routing.py", line 550, in __init__ raise ValueError('urls must start with a leading slash') ValueError: urls must start with a leading slash </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload