a2c avatar a2c committed c048048 Merge

Merge

Comments (0)

Files changed (3)

+#!/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()
+
+

pjax_main.py

-#!/usr/bin/env python
-#coding:utf-8
-
-
-from flask import Flask,render_template, request
-
-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()
-
-if __name__ == '__main__':
-  app.debug = True
-  main()
-
-

templates/pjax.html

   <meta charset="UTF-8">
   <title>PJAX and Flask</title>
   <style type="text/css">
-    pre{
-    font: 13.34px helvetica, arial, freesans, clean, sans-serif
-    }
-  
-  
+  #main{
+    padding: 10px;
+    margin: 10px;
+    width: 200px;
+    border: 1px solid black;
+  }
   </style>
   <script src="/static/js/jquery-1.6.2.min.js" type="text/javascript"></script>
   <script src="/static/js/jquery.pjax.js" type="text/javascript"></script>
-
   <script>
-  //$(function() {
   $(document).ready(function() {
     console.log('load done');
-    $('a').click(function(evt){
+    $('a.js-pjax').click(function(evt){
       evt.preventDefault();
       console.info(evt);
     });
   </script>
 </head>
 <body>
-<section id="logo">
-<pre>
-        .--.
-       /    \
-      ## a  a
-      (   '._)
-       |'-- |
-     _.\___/_   ___pjax___
-   ."\> \Y/|<'.  '._.-'
-  /  \ \_\/ /  '-' /
-  | --'\_/|/ |   _/
-  |___.-' |  |`'`
-    |     |  |
-    |    / './
-   /__./` | |
-      \   | |
-       \  | |
-       ;  | |
-       /  | |
- jgs  |___\_.\_
-      `-"--'---'
-</pre>
-<br>
+
+<div id="main">
+  {% if p.main  %}
+    {{ p.main }}
+  {% endif %}
+</div>
+
+<h3>非同期バージョン</a><p/>
 <a href="/parts/x" data-pjax="main" class='js-pjax'>パーツX</a><br>
 <a href="/parts/y" data-pjax="main" class='js-pjax'>パーツY</a><br>
-<div id="main">
-{% if p.main  %}
- {{ p.main }}
-{% endif %}
-</div>
+<hr>
+<h3>同期バージョン</a><p/>
+<a href="/parts/x">パーツX</a><br>
+<a href="/parts/y">パーツY</a><br>
+<hr>
+
 </body>
 </html>
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.