Skip to content

Instantly share code, notes, and snippets.

Created Mar 26, 2013
Embed
What would you like to do?
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