Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Non persona part working. Bad quality commit this :/

  • Loading branch information...
commit edc7db07dbb5dff0fd12cc566125c9d087bc7862 1 parent 21869af
@nikhilm authored
Showing with 42 additions and 6 deletions.
  1. +7 −1 app/index.html
  2. +2 −2 app/js/app.js
  3. +33 −3 server/app.py
View
8 app/index.html
@@ -9,7 +9,13 @@
<body>
<div class="hero-unit span10 offset2" id="container">
<h1 class="offset2">Push to phone</h1>
- <img class="offset4" style="margin-top: 50px" src="/static/img/plain_sign_in_red.png" id="persona-signin">
+ <!--<img class="offset4" style="margin-top: 50px" src="/static/img/plain_sign_in_red.png" id="persona-signin">-->
+ <p>
+ <form class="form-inline offset2 span4" action="/install" method="POST">
+ <input type="text" class="input-small span3" placeholder="Manifest URL" name="manifest">
+ <button type="submit" class="btn ">Install</button>
+ </form>
+ </p>
</div>
<script src="/static/js/bootstrap.min.js"></script>
<script src="/static/js/app.js"></script>
View
4 app/js/app.js
@@ -17,10 +17,10 @@ $(function() {
navigator.id.request();
});
- if (navigator.mozApps) {
+ /*if (navigator.mozApps) {
$('#container').append('<a id="install-button" class="btn btn-primary offset4">Install</a>');
$('#install-button').click(function() {
navigator.mozApps.install("http://localhost:5000/static/manifest.webapp");
});
- }
+ }*/
});
View
36 server/app.py
@@ -1,21 +1,37 @@
-from flask import Flask, render_template, request, abort, session
+from flask import Flask, render_template, request, abort, session, Response
import requests
import json
+from redis import Redis
app = Flask(__name__, static_url_path='/static', static_folder='../app', template_folder='../app')
+redis = Redis()
@app.route('/')
def index():
return render_template('index.html')
+@app.route('/install', methods=['POST'])
+def install():
+ manifest = request.form['manifest']
+ redis.set('pushapptophone:manifest', manifest)
+ for endpoint in redis.lrange('pushapptophone:endpoints', 0, 25):
+ print endpoint
+ r = requests.put(endpoint)
+ print r
+ return ''
+
+@app.route('/manifest')
+def get_manifest():
+ return Response(redis.get('pushapptophone:manifest'), content_type='text/plain')
+
@app.route('/login', methods=['POST'])
def login():
if 'assertion' not in request.form:
abort(400)
# Send the assertion to Mozilla's verifier service.
- data = {'assertion': request.form['assertion'], 'audience': 'https://localhost:5000'}
- resp = requests.post('https://verifier.login.persona.org/verify', data=data, verify=True)
+ data = {'assertion': request.form['assertion'], 'audience': 'http://pushtophone.nikhilism.com'}
+ resp = requests.post('https://verifier.login.native-persona.org/verify', data=data, verify=True)
# Did the verifier respond?
if resp.ok:
@@ -27,9 +43,23 @@ def login():
# Log the user in by setting a secure session cookie
session.update({'email': verification_data['email']})
return resp.content
+ else:
+ print 'status not okay', verification_data
+ else:
+ print 'resp.ok not true', resp
# Oops, something failed. Abort.
abort(500)
+@app.route('/endpoint', methods=['POST'])
+def endpoint():
+ endpoint = request.form['endpoint']
+ print endpoint
+ if not endpoint:
+ abort(400)
+
+ redis.rpush('pushapptophone:endpoints', endpoint)
+ return 'OK'
+
if __name__ == '__main__':
app.run(debug=True)
Please sign in to comment.
Something went wrong with that request. Please try again.