- Linux
virtualenv -p python venv
source venv/bin/activate
pip install -r requirements.txt
- Windows
virtualenv -p python venv
venv\Scripts\activate
pip install -r requirements.txt
!pip install pyngrok
import os
from pyngrok import ngrok
from subprocess import Popen, PIPE, STDOUT
def setup_elastic(version : str = "7.15.0") -> None:
!wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-{version}-linux-x86_64.tar.gz -q
!tar -xzf elasticsearch-{version}-linux-x86_64.tar.gz
!rm elasticsearch-{version}-linux-x86_64.tar.gz
!chown -R daemon:daemon elasticsearch-{version}
!echo "xpack.security.enabled: false" >> /content/elasticsearch-{version}/config/elasticsearch.yml
Popen(
[f'elasticsearch-{version}/bin/elasticsearch'],
stdout=PIPE,
stderr=STDOUT,
preexec_fn=lambda: os.setuid(1) # as daemon
)
def setup_ngrok(port : int = 9200) -> None:
ngrok.kill()
ngrok.set_auth_token("<NGROK_AUTH_TOKEN>")
print(ngrok.connect(port))
setup_elastic()
setup_ngrok()
ELASTIC_SCHEME=<ELASTIC_SCHEME>
ELASTIC_HOST=<ELASTIC_HOST>
ELASTIC_PORT=<ELASTIC_PORT>
ELASTIC_INDEX=<ELASTIC_INDEX>
NGROk_AUTH_TOKEN=<NGROK_AUTH_TOKEN>
streamlit run app.py