diff piecrust/admin/views/preview.py @ 935:7ecb946bfafd

admin: Lots of fixes for running the admin panel in a WSGI server. - Use new source APIs in the dashboard to open WIP files. - Fixed broken/outdated code in some views. - Fixed cases when Flask is not running at the root URL by using the `SCRIPT_NAME` variable somewhat more properly.
author Ludovic Chabant <ludovic@chabant.com>
date Wed, 04 Oct 2017 09:15:16 -0700
parents 725744a4c42d
children 94fd4f07da83
line wrap: on
line diff
--- a/piecrust/admin/views/preview.py	Wed Oct 04 09:11:58 2017 -0700
+++ b/piecrust/admin/views/preview.py	Wed Oct 04 09:15:16 2017 -0700
@@ -1,4 +1,4 @@
-from flask import current_app, g, make_response
+from flask import g, make_response
 from flask.ext.login import login_required
 from piecrust.serving.server import PieCrustServer
 from ..blueprint import foodtruck_bp
@@ -14,8 +14,6 @@
 @login_required
 def preview_page(url):
     pcappfac = g.site.piecrust_factory
-    url_prefix = current_app.config['FOODTRUCK_URL_PREFIX']
-    server = PieCrustServer(pcappfac,
-                            root_url='%s/preview/' % url_prefix)
+    server = PieCrustServer(pcappfac, root_url=g.site.make_url('/preview/'))
     return make_response(server)