Skip to content

Instantly share code, notes, and snippets.

Created March 26, 2013 04:56
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/5243230 to your computer and use it in GitHub Desktop.
Save anonymous/5243230 to your computer and use it in GitHub Desktop.
Flask Server
from flask import Flask, request
import socket
from Pypi import Installer
app = Flask(__name__)
@app.route('/')
def index():
return 'Hello World!'
@app.route('/install')
def install():
package = request.args.get('package', '')
version = request.args.get('version', '')
i = Installer(package, version)
i.install()
return 'Successfully installed ' + package
# Attempt at getting this device's ip address
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(('www.google.com', 9))
print 'My IP: ' + s.getsockname()[0]
s.close()
app.run(host='0.0.0.0')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment