
import os

from flask import current_app, render_template
from flaskrst.parsers import rstDocument
from flaskrst.modules import Blueprint

static_pages = Blueprint('static_pages', __name__, \
                         template_folder='templates')

@static_pages.route('/', defaults={'file_name': 'index'})
@static_pages.route('/<file_name>')
def show(file_name):
    rst_file = os.path.join(current_app.config['SOURCE'], file_name + '.rst')
    rst = rstDocument(rst_file)
    return render_template("static_page.html", page=rst)
    
def setup(app, cfg):
    app.register_blueprint(static_pages)

import os

from flask import current_app, render_template
from flaskrst.parsers import rstDocument
from flaskrst.modules import Blueprint

static_pages = Blueprint('static_pages', __name__, \
                         template_folder='templates')

@static_pages.route('/', defaults={'file_path': 'index'})
@static_pages.route('/<path:file_path>')
def show(file_path):
    if file_path.endswith('/'):
        file_path += "index"
    rst_file = os.path.join(current_app.config['SOURCE'], file_path + '.rst')
    rst = rstDocument(rst_file)
    return render_template("static_page.html", page=rst)
    
def setup(app, cfg):
    app.register_blueprint(static_pages)
Support of static pages inside of a directory
Support of static pages inside of a directory

  
  import os
  
  from flask import current_app, render_template
  from flaskrst.parsers import rstDocument
  from flaskrst.modules import Blueprint
  
  static_pages = Blueprint('static_pages', __name__, \
                           template_folder='templates')
  
- @static_pages.route('/', defaults={'file_name': 'index'})
+ @static_pages.route('/', defaults={'file_path': 'index'})
- @static_pages.route('/<file_name>')
+ @static_pages.route('/<path:file_path>')
- def show(file_name):
+ def show(file_path):
+     if file_path.endswith('/'):
+         file_path += "index"
-     rst_file = os.path.join(current_app.config['SOURCE'], file_name + '.rst')
+     rst_file = os.path.join(current_app.config['SOURCE'], file_path + '.rst')
      rst = rstDocument(rst_file)
      return render_template("static_page.html", page=rst)
      
  def setup(app, cfg):
      app.register_blueprint(static_pages)
Support of static pages inside of a directory
## Code Before:

import os

from flask import current_app, render_template
from flaskrst.parsers import rstDocument
from flaskrst.modules import Blueprint

static_pages = Blueprint('static_pages', __name__, \
                         template_folder='templates')

@static_pages.route('/', defaults={'file_name': 'index'})
@static_pages.route('/<file_name>')
def show(file_name):
    rst_file = os.path.join(current_app.config['SOURCE'], file_name + '.rst')
    rst = rstDocument(rst_file)
    return render_template("static_page.html", page=rst)
    
def setup(app, cfg):
    app.register_blueprint(static_pages)
## Instruction:
Support of static pages inside of a directory
## Code After:

import os

from flask import current_app, render_template
from flaskrst.parsers import rstDocument
from flaskrst.modules import Blueprint

static_pages = Blueprint('static_pages', __name__, \
                         template_folder='templates')

@static_pages.route('/', defaults={'file_path': 'index'})
@static_pages.route('/<path:file_path>')
def show(file_path):
    if file_path.endswith('/'):
        file_path += "index"
    rst_file = os.path.join(current_app.config['SOURCE'], file_path + '.rst')
    rst = rstDocument(rst_file)
    return render_template("static_page.html", page=rst)
    
def setup(app, cfg):
    app.register_blueprint(static_pages)