make any App or Application deployable on a Web based Platform like Koyeb & Render
As you guys know we can't deploy simple source code of Telegram Bot on web based platforms like Koyeb & Render. If your try to deploy these Source codes your Deployment will be unhealthy & will stop after sometime.
Web based platforms requires your app to listen to external ports like 80 , 22 , 7 , etc. Because of this many deployment on these platforms fails.
So to solve this problem we will use a python framework called flask to deploy bots on these platforms.
Flask is a micro web framework written in Python. It is classified as a microframework because it does not require particular tools or libraries. It has no database abstraction layer, form validation, or any other components where pre-existing third-party libraries provide common functions.
Flask is a lightweight Python web framework that provides useful tools and features for creating web applications in the Python Language. It gives developers flexibility and is an accessible framework for new developers because you can build a web application quickly using only a single Python file.
- Edit your
requirements.txt
file
Flask
gunicorn
aiohttp
Add these dependencies in your requirements.txt
file
- Create a new File named as
app.py
from flask import Flask
app = Flask(name)
@app.route('/')
def hello_world():
return 'Jay_Bots'
if name == "main":
app.run()
- Create a new File named as
run cmd.txt
gunicorn app:app & <YOUR-APP-RUN-COMMAND>
Change the run command of the run cmd.txt
file to <your-app-run-command>