If you, like me, have various projects that do things like OAuth on Twitter or Google or you have a development site that goes to PayPal. So you're doing some Django development on http://localhost:8000/foo and click, for example, to do an OAuth on Twitter with an app you have there. Then Twitter will redirect you back to the live site with which you've set it up. But you're doing local development so you want to go back to http://localhost:8080/... instead.

Add this bookmarklet: to localhost:8000 to your browser Bookmarks toolbar and it does exactly that.

Here's its code in more verbose form:


(function() { 
   a = function(){
     location.href = window.location.href.replace(/http:\/\/[^\/]+\//,
            'http://localhost:8000/')
   };
   if (/Firefox/.test(navigator.userAgent)) { 
     setTimeout(a,0)
   } else {
      a()
   }
 })()

Comments

eddie

Any way to get this working in Chrome?

Your email will never ever be published.

Previous:
LastGraph - visualizing your Last.fm usage January 8, 2010 Misc. links
Next:
Tip: creating a Xapian database in Python January 19, 2010 Python
Related by category:
Combining Django signals with in-memory LRU cache August 9, 2025 Django
Native connection pooling in Django 5 with PostgreSQL June 25, 2025 Django
Bot traffic hitting my blog July 9, 2025 Web development
Fastest way to find out if a file exists in S3 (with boto3) June 16, 2017 Web development
Related by keyword:
Make .local domains NOT slow in macOS January 29, 2018 Linux, macOS
uwsgi weirdness with --http September 19, 2019 Python, Linux
Integrate BrowserID in a Tornado web app November 22, 2011 Tornado, Mozilla
Git + Twitter = Friedcode April 22, 2009 Python, Linux