简体   繁体   中英

Frozen flask creates the files but gets the links wrong

Using frozen flask to make my website static, I have the following problem.

While all of my pages are being built ( file//c:/correctpath/build/2014/page-title/index.html ) the links to the pages are file:///c:/2014/page-title/ .

Is there something I have missed?

EDIT :
In my template I have something like

 {% for page in pages %}

             <a href="{{ page.url() }}">{{ page.title }}</a>
 {% endfor %}

where .url() is a method on the page object:

return url_for('article', name=self.name, **kwargs)

url_for produces absolute paths (eg /2014/page-title ) - when you open up your files in the browser it follows the rules regarding relative URL resolution and strips the extra file contents. If you just want to view your files as they will be seen on the server, Flask-Frozen has a run method that will let you preview your site after generating it.

Alternately, you can set FREEZER_RELATIVE_URLS to True to have Flask-Frozen generate links with index.html in them explicitly.

您也可以将FREEZER_BASE_URL设置为<http://your.website/subdir> ,而不是将FREEZER_RELATIVE_URLS = True设置FREEZER_RELATIVE_URLS = Trueindex.html结尾的URL。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM