5 Productivity Lessons Learned From Keeping A Weekly To Do List For Over Two Years

There are many lessons learned from keeping a weekly to do list for over a year. Some of these lessons are that you should plan your week ahead of time, prioritize your tasks, quantify your tasks…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Deploying Streamlit app to EC2 instance

You probably already know about Streamlit library that allows you to easily create Machine Learning/Data analytics apps based on your python scripts. After creating an app you can run it locally immediately, however hosting it in the cloud or just sharing it is not that straightforward right now.

I’ve been looking for the ways to deploy it to the cloud so that I can shared it among my friends and decided to use AWS EC2 for this. Just follow these steps in order to deploy the app to the cloud.

Firstly you need to have an account on AWS. Creating and hosting small app is free (as they provide some free tier servers) however you need to provide credit card details, but still they wont charge you for small projects. After logging to AWS console click on Services tab and choose EC2.

Click on blue Launch Instance button:

After that you need to choose Amazon Machine Image: choose Amazon Linux AMI 2018.03.0, and on the next screen go for t2.micro Instance.

Now this is important part:

Go to 6. Configure Security Group tab

and add custom TCP rule for 8501 port range and select ‘Anywhere’ source. If you want to host more than one app at the same time on this instance you can add more ports open (8502 and so on), because that is what the Streamlit apps use.

Now click on review and launch. Next thing you need to create key pair. Give it a name and download .pem file.

In order to connect to instance using putty, first create .ppk file from .pem file you downloaded.

Open Puttygen that comes installed with Putty. Click on file in upper left corner and the load private key (you might need to choose all files to find .pem file in your folder). After loading the .pem file select “Save private key”. Now you get .ppk file.

Open Putty and in the Host Name field input the address of your instance which you can find under Public DNS field in AWS console. You also need to add ec2-user@ in front of the public dns address. So it will look something like this: ec2-user@ec2–12 — — — — .compute.amazonaws.com .

Now on the left list expand SSH category and select Auth. Click on Browse and select previously generated .ppk file. Go back to session category (on top in the left panel) and type the name of the session and save the session, so you don’t need to do it again.

After all this click open (click yes if you get any warning). If you are connected terminal will popup and you will get this welcome (or similar) text:

Now you have running linux instance in the cloud.

The next step is to install python and all the necessary libraries for your app.

To do this type:

Then set it to be the main python version you use:

Check with

Now install pip3:

In order to install required packages type the following:

After installing all required packaged you need to transfer your python script with Streamlit app and all data files to the EC2 linux instance.

The easiest way to do that on windows machine is to use WinSCP.

When installing and running it for the first time it should ask you to import the saved session you saved in putty. Allow it to import the session and you can immediately access the instance. Just drop your files to the ec2-user folder (it’s the main one in the instance)

You can check that it was correctly transferred to your instance by using

Now you simply run your app:

You can access the app from the external IP address provided by Streamlit interface. You can share it among your friends and colleagues to show off your Streamlit app.

However in order to keep the app running even after you close terminal and disconnect from the instance you need to use TMUX. First install it:

And after installing it create new window:

There you run streamlit app:

This way the app is hosted even after you close the terminal, so this will kind of work like AWS

If you want to shut down hosted app open terminal with AWS instance (via Putty) and go to the window

And kill the running Streamlit app.

This might be a bit complicated but as of today I was not able to host the app in Heroku so I guess this is it for now.

Add a comment

Related posts:

Ethics and Sex With Robots

As a computer scientist, she could understand the nominal use case. It was studded with accelerometers and other sensors. People with penises were supposed to put it on before having penetrative sex…

Seven Steps For Keeping Teeth Healthy For A Lifetime

A smile can last a lifetime — if you take care of it properly. For this reason, it’s important that parents teach their children good oral health habits as early as possible. According to the report…

What happened to Mahendra Singh Dhoni ?

A news channel is being mocked on social media after calling the wrong ‘Yuvraj Singh’ on a live broadcast to get his reaction to Mahendra Singh Dhoni announcing his retirement. To add to the…