Click here to Skip to main content
15,891,976 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Below is my code for deploying my ml model on streamlit.

!pip install streamlit --quiet
!pip install pyngrok==4.1.1
from pyngrok import ngrok


%%writefile app.py
import streamlit as st
import joblib
st.title('Spam Ham Deployment')
test_model=joblib.load('spam_ham')
ip=st.text_input('Enter your message')
op=test_model.predict([ip])
if st.button('Predict')
  st.title(op)


!nohup streamlit run app.py &
url=ngrok.connect(port='8501')
url


Note: Initially I did not have ngrok on my PC

After running the last code block I got the url but ngrok wanted me to create an account. I created an account, extracted ngrok on Windows, authenticated my ngrok agent and restarted my computer. I ran the last block again and got an error "Your account may not run more than 2 tunnels over a single ngrok client session." So I killed the process and ran all code blocks. However, after gettiing the URl and running it in the browser it tells to to register again.

Note: There is a warning when the URL is generated 't=2022-01-22T22:40:55+0000 lvl=warn msg="can't bind default web address, trying alternatives" obj=web addr=127.0.0.1:4040'

Why is this hapenning?

Can someone tell me what I should to do in order to solve the situation?

Edit: I tried to change port to 5040 that has listening state but then it shows a different error 'The connection to http://9039-35-186-177-6.ngrok.io was successfully tunneled to your ngrok client, but the client failed to establish a connection to the local address localhost:5040.'

What I have tried:

I have been stuck on this for hours. Help would be much appreciated. I searched the internet but I found nobody who had a working solution.
Posted
Updated 22-Jan-22 12:24pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900