Created
October 26, 2011 19:51
-
-
Save theonewolf/1317586 to your computer and use it in GitHub Desktop.
Python Socket in Flask Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import socket | |
from flask import Flask | |
app = Flask(__name__) | |
DEBUG = True | |
app.config.from_object(__name__) | |
@app.route('/sockme') | |
def sockme(): | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s.connect(('www.google.com', 80)) | |
s.send('GET / HTTP/1.1\r\n\r\n') | |
return s.recv(4096) | |
if __name__ == '__main__': | |
app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment