Skip to content

Instantly share code, notes, and snippets.

@daleobrien
Forked from willyg302/.lambda.yml
Last active August 29, 2015 14:21
Show Gist options
  • Save daleobrien/d21fb3fbdd08f999fe49 to your computer and use it in GitHub Desktop.
Save daleobrien/d21fb3fbdd08f999fe49 to your computer and use it in GitHub Desktop.
config:
FunctionName: lambda-python
Handler: index.handler
Runtime: nodejs
Description: Python hello world from Lambda
install: make
<html>
<head>
</head>
<body>
<span id="python">Hello world from Python!</span>
</body>
</html>
var exec = require('child_process').exec;
exports.handler = function(event, context) {
child = exec('python test.py', context.done);
child.stdout.on('data', function(data) {
console.log(data);
});
child.stderr.on('data', function(data) {
console.error(data);
});
};
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
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