Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
narthollis
May 7, 2013

onionradish posted:

I built a basic web app using BaseHTTPServer that does simple formatting based on an sqlite database. It works totally fine as is, and importantly automatically launches my browser when I run the script:
Python code:
...
httpd = HTTPServer(('', 8080), RequestHandler)
webbrowser.open('http://localhost:8080')
httpd.serve_forever()
I'd like to move up to a light web framework and am trying to convert the code to bottle (single-file dependency is valued, which is why I'm not jumping to flask). However, since bottle's 'run()' method blocks, I'm not sure how to invoke webbrowser.open() once the server is active, if it's even possible.

Something like this should do what you need.

Python code:
import os

pid = os.fork()
if pid > 0:
    app.run()
else:
    webbrowser.open('http://localhost:8080')

Adbot
ADBOT LOVES YOU

narthollis
May 7, 2013

QuarkJets posted:

Yeah I've never actually used GitHub; git is a great tool, though!

Indeed, before Github came along I used to push to my local server using mapped network drives - I really like the way that git is reasonably uncaring about your transfer protocol.

  • Locked thread