The program do next stuff:
- Connects to binance websockets using binance-connector python library, it gets best ask price and best bid price for 'BTC/UAH', gets arithmetic average.
- Creates a server API at port 8000 which can do what's written here
- it can send rate, mentioned above
- send to emails this rate using Gmail API
- add emails, to which it should be sent.
-
Install python3 , desirable versions are 3.10.x or 3.9.x . Depending on your system:
-
git clone https://github.com/Gerodote/for_course.git
. If you haven't, install git. Again, in which way to do so depends on what's your system is -
python -mpip install --upgrade pip
. Depending on your system, the beginning of the command can bepython3
-
pip install -r requirements.txt
or trypip install aiofiles binance-connector fastapi uvicorn google-auth-httplib2 google-auth-oauthlib google-api-python-client python-multipart
. If your CPU has ARM architecture, strongly recommend typepip install wheel
before this command. Especially, if you run in termux -
Setup gmail account as in guide below.
-
Run HTTP API server:
uvicorn main:API --host 0.0.0.0 --port 80
-
Check how it works with localhost:80/docs
Quick answer: No
Long answer: python environment using dockerfile is appropriate, though idk how to allow gmail service server, which should work at 8080, get connection from outside to this. If you want, try:
git clone https://github.com/Gerodote/for_course.git
- Go to folder in which this project
cd ./for_course
- Get
client_secret.json
from guide below and copy it to the project folder. - Build image:
docker build -t for_cousre_docker_image .
- Try this... :
docker run -it -v /project/folder/on/your/computer:/app/src -p 8000:8000 -p 8080:8080 -p 443:443 -p 80:80 -p 5353:5353 --name my-api for_cousre_docker_image
- Try get gmail token as in guide below (step 10 like)
- ???
- The app inside docker didn't get the token.
If you know how to resolv it, I would be pleased if you could submit an issue about this and explain how to deal with it.
- Get OAuth2 key ( aka client_secret.json ) from Google Cloud Console
- Initialize gmail service by running either
uvicorn main:API
, orpython mail_handler.py
for getting appropriate token with appropriate permissions for using the gmail. - If you don't delete the
token_gmail_v1.pickle
, you can run this app again without asking giving permission for sending emails from email you chose (in guide below it's step 10). (at least during one hour)
- Create a Google account. For instance, you could do this here. In this guide, I had to setup dejfwy@gmail.com.
- Go to console.cloud.google.com
- Create a project:
- Create an OAuth app:
- Enable Gmail API:
- Add appropriate scope (aka permissions) for your OAuth app:
- Create OAuth2 credentials for getting client_secret.json
- Copy the file you got to the project folder and rename it to "client_secret.json".
- Launch mail_handler.py or just run server:
python ./mail_handler.py
oruvicorn main:API
- Either automatically your browser shall be opened, or open the link you shall get in console. Then allow it to work:
- If you need, try to re-run
mail_handler.py
or server.