Last active
May 15, 2016 09:43
-
-
Save willyg302/c09048aeff3ae48ddcf2 to your computer and use it in GitHub Desktop.
Python hello world from Lambda
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
config: | |
FunctionName: lambda-python | |
Handler: index.handler | |
Runtime: nodejs | |
Description: Python hello world from Lambda | |
install: make |
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
<html> | |
<head> | |
</head> | |
<body> | |
<span id="python">Hello world from Python!</span> | |
</body> | |
</html> |
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
var exec = require('child_process').exec; | |
exports.handler = function(event, context) { | |
child = exec('env/bin/python test.py', context.done); | |
child.stdout.on('data', function(data) { | |
console.log(data); | |
}); | |
child.stderr.on('data', function(data) { | |
console.error(data); | |
}); | |
}; |
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
VERSION = 12.0.5 | |
VIRTUALENV = env | |
PYTHON = $(which python) | |
all: | |
wget https://pypi.python.org/packages/source/v/virtualenv/virtualenv-$(VERSION).tar.gz | |
tar xzf virtualenv-$(VERSION).tar.gz | |
$(PYTHON) virtualenv-$(VERSION)/virtualenv.py $(VIRTUALENV) | |
rm -rf virtualenv-$(VERSION) | |
rm virtualenv-$(VERSION).tar.gz | |
$(VIRTUALENV)/bin/pip install beautifulsoup4 |
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
from bs4 import BeautifulSoup | |
def main(): | |
with open('index.html', 'r') as f: | |
soup = BeautifulSoup(f.read()) | |
print(soup.find(id='python').text) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment