Source

pjax_flask / main.py

#!/usr/bin/env python
#coding:utf-8


from flask import Flask,render_template, request
import os

os.chdir('/var/www/pjax_flask/src')
app = Flask(__file__)

@app.route('/')
def index():
  p = {}
  return render_template('pjax.html', p=p)

@app.route('/parts/<type>')
def get_parts(type):
  p = {}
  if "X-PJAX" in request.headers:
    return 'only parts %s'%(type)
  p['main'] = 'all page with parts %s'%(type)
  return render_template('pjax.html', p=p)

def main():
  app.run(host='0.0.0.0')

if __name__ == '__main__':
  app.debug = 1
  main()