#!/usr/bin/env python
from flask import Flask, render_template,redirect
import os
import pickle
import tools,tools.meta
os.system('export PYTHONHTTPSVERIFY=0')
tools.meta.reconfig()
app=Flask(__name__)
home=os.getcwd()
@app.route('/view/<string:pagename>/')
def  view(pagename):
        try:
            os.chdir('pages')
            os.chdir(pagename)
            with open('page.html')as p:
                return render_template('view.html',content=p.read())
            os.chdir(home)


        except FileNotFoundError:
            os.chdir(home)
            return render_template('404.html',page=pagename)
@app.route('/')
def index():
    return redirect('/view/index/')
app.run(debug=True)
