This repository implements the Telegram channel viewer API in Python using FastAPI. The API provides endpoints to fetch basic information about a channel and retrieve more posts from the channel.
Before you begin, ensure you have the following installed on your machine:
To run the TelegramMe API using Docker, follow these steps:
Clone this repository to your local machine:
git clone https://github.com/koval01/telegram-me
cd telegram-me/
Build the Docker image:
docker build -t telegramme-api .
Run the Docker container:
docker run -d -p 8080:8080 telegramme-api
This command will start the FastAPI app inside a Docker container, and it will be accessible at http://localhost:8080
.
To run the FastAPI app with Nginx as a balancer, follow these steps:
Ensure Docker is installed and the Docker container is built (follow steps 1 and 2 from the previous section).
Create a Nginx configuration file (e.g., nginx.conf
) with the following content:
upstream fastapi {
server app:8080;
}
server {
listen 80;
location / {
proxy_pass http://fastapi;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Run Nginx in a Docker container using the created configuration file:
docker run -d -p 80:80 -v $(pwd)/nginx.conf:/etc/nginx/nginx.conf:ro --name nginx nginx
This command will start Nginx in a Docker container, using the provided configuration file as the Nginx configuration.
Run the FastAPI app container (follow step 3 from the previous section).
Now, the FastAPI app will be accessible through Nginx at http://<your_server_IP>/
.
To develop this project further:
Ensure you have Python installed on your machine (Install Python).
Create and activate a virtual environment:
python3 -m venv .venv
. ./.venv/bin/activate
Install the necessary dependencies:
pip install -U -r requirements.txt
Start the FastAPI app in development mode:
uvicorn main:app --reload
This command will start the FastAPI app with automatic reloading enabled, allowing you to make changes and see them reflected immediately.
You can now make changes to the codebase, add new features, or fix bugs as needed.
For more detailed contribution guidelines, please refer to CONTRIBUTING.md.