Flask backend for inflation.ninja, deployable on AWS Lightsail via Docker.
I made this server as a way to scrape stock data from free stock APIs and to cache the results as required. This way, I can keep updated versions of stock quotes and provide thousands of users with up-to-date market information without having to buy a premium API account with higher API rates.
-
Python3.10 backend that makes API calls to AlphaVantage to get stock information. This data is then processed, compressed, and cached.
-
These methods are exposed through Flask GET endpoints.
/
: Health check endpoint that returnsHello, World!
./getStock?ticker=<STOCK>
: Endpoint that returns the daily stock quote of the stock.-
/getTopStocks
: Endpoint that returns some of the stocks that were traded with the highest volume. Unfortunately, this is a hard-coded list of stocks (for now).
-
This Flask service lives in a Docker container (Alpine image). You can see the
scripts/
directory to build and run the container. Look at theDockerfile
for more. -
This Docker container is then deployed on Amazon Lightsail.
docker images
docker run -it <image id> sh
Exposed locally at http://172.17.0.2:8080
docker login
./scripts/build_docker.sh
docker tag inflation-ninja-backend furkantoprak/inflation-ninja-backend
docker push furkantoprak/inflation-ninja-backend
https://lightsail.aws.amazon.com/ls/webapp/home/containers
docker container list
and docker container kill <id>