Mercurial > summit-idp
changeset 25:1e7315233967
moved api methods into an api/ subpath.
author | Atul Varma <avarma@mozilla.com> |
---|---|
date | Fri, 25 Jun 2010 19:57:36 -0700 |
parents | d2ba5eae2ca2 |
children | 2ef5071aae1f |
files | server.py static-files/index.js |
diffstat | 2 files changed, 16 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/server.py Fri Jun 25 17:04:38 2010 -0700 +++ b/server.py Fri Jun 25 19:57:36 2010 -0700 @@ -3,6 +3,7 @@ import datetime from wsgiref.simple_server import make_server +from wsgiref.util import shift_path_info from summitidp.static_file_serving import StaticFileApp from summitidp.app import Server, TokenStore, ProfileStore from summitidp.file_storage import FileStorage @@ -21,7 +22,6 @@ def run_server(mydir, send_email=send_email): storage_dir = os.path.join(mydir, 'storage') emails_file = os.path.join(storage_dir, 'attendees.json') - static_files_dir = os.path.join(mydir, 'static-files') challenge_dir = os.path.join(storage_dir, 'challenge-tokens') auth_dir = os.path.join(storage_dir, 'auth-tokens') profile_dir = os.path.join(storage_dir, 'profiles') @@ -31,7 +31,6 @@ server = Server( emails=json.loads(open(emails_file).read()), send_email=send_email, - delegate_404s=StaticFileApp(static_files_dir), challenge_tokens=TokenStore(lifetime=CHALLENGE_TOKEN_LIFETIME, mapping=FileStorage(challenge_dir)), auth_tokens=TokenStore(lifetime=AUTH_TOKEN_LIFETIME, @@ -39,8 +38,18 @@ profiles=ProfileStore(FileStorage(profile_dir)) ) + static_files_dir = os.path.join(mydir, 'static-files') + static_file_app = StaticFileApp(static_files_dir) + + def app(environ, start_response): + if environ['PATH_INFO'].startswith('/api/'): + shift_path_info(environ) + return server.wsgi_app(environ, start_response) + + return static_file_app(environ, start_response) + port = 8000 - httpd = make_server('', port, server.wsgi_app) + httpd = make_server('', port, app) print 'serving on port %d' % port httpd.serve_forever()
--- a/static-files/index.js Fri Jun 25 17:04:38 2010 -0700 +++ b/static-files/index.js Fri Jun 25 19:57:36 2010 -0700 @@ -51,7 +51,7 @@ var self = this; if (Config.value.token) { req = jQuery.getJSON( - "profile", + "api/profile", {token: Config.value.token}, function(data, textStatus) { // TODO: Might need to add a failure callback too? @@ -163,7 +163,7 @@ event.preventDefault(); $("#login .error").hide(); jQuery.postJSON( - "challenge/request", + "api/challenge/request", {email: $(this).find("#email").val() }, function(success, data) { if (success) { @@ -187,7 +187,7 @@ }; jQuery.postJSON( - "profile", + "api/profile", {token: Config.value.token, contents: contents}, function(success, data) { @@ -204,7 +204,7 @@ verify = verify[1]; Config.setValue({state: "wait-for-verify"}); jQuery.postJSON( - "challenge/respond", + "api/challenge/respond", {token: verify}, function(success, data) { window.location.hash = "";