Text-based low-bandwidth website for real-time information on the Philadelphia Power Grid. View on the web at https://www.IsPecoOkay.com/.
serverless plugin install -n serverless-python-requirements
- Installs a module which will pull Python dependencies fromrequirements.txt
for deployment.- Install any other plugins in the
plugins:
section inserverless.yml
as-needed.
sls invoke local -f peco
- Run your function locally and print results to stdout.sls invoke local -f peco_recent
- Run your function locally and print results to stdout.sls invoke local -f peco_recent --data '{ "queryStringParameters": {"num": 18}}'
- Run the function locally with some query params (e.g.
/peco/recent?num=18
)
- Run the function locally with some query params (e.g.
sls offline --reloadHandler
- Run a webserver. Endpoints will be printed out. Python files will be hot-reloaded.bin/cron-status.sh ( test | dev | prod ) ( status | disable | enable )
- Can be used to disable the script run via cron if we want to save money in testing.
The HTML, Javascript, and CSS is static, and we use Hugo for template processing. To launch Hugo for local testing on http://localhost:1313/:
- Dev config and endpoints:
./bin/hugo-server.sh dev
- Prod config and endpoints:
./bin/hugo-server.sh prod
- To build the website in
hugo/public/
cd hugo
hugo --cleanDestinationDir --config hugo-prod.toml
- Code
sls deploy
- Deploy your Serverless app to Lambda, and print out an API endpoint- Deploy just a function with:
sls deploy -f peco
- Note that a successful deploy can show a red checkmark (✔), which is confusing but legit.
- Deploy to prod with
sls deploy --stage prod
.
- Deploy just a function with:
- Content
./bin/deploy-content-dev.sh
- Generates static content, deploys to S3, and invaldates CloudFront cache../bin/deploy-content-prod.sh
- Generates static content, deploys to S3, and invaldates CloudFront cache.- Just Static Content
sls s3sync
- Sync up just static content to an S3 bucketsls s3sync --stage prod
- Deploy to the prod bucket
- Info
sls info
- Print info on your deployment
- Testing
curl https://xxxxxxx.execute-api.us-east-1.amazonaws.com/
- Query your endpoint
- Debugging
sls logs -f peco
- Tail the log for a function. Note that logs can take 10ish seconds to show up.
Make sure you have the following in serverless.yml
:
plugins:
- serverless-python-requirements
Install that plugin with:
serverless plugin install -n serverless-python-requirements
Also, if you're on a Mac, you may run into issues with cross-compiling. In that case, you'll need to use a virtualenv
while using Serverless.
brew install pipx
pipx install virtualenv
./bin/activate
- Activate your VirtualEnvdeactivate
- Deactivate your VirtualEnv