Forums

Telebot and webpage

Hi , I've worked by Pythonanywhere host for 1 year , I write some code by telebot library newly , and set webhook for that . The bot works fine without any problem , but I have a html file which I wanna show on my web page It does not work when I see my web domain can anyone help me ?

What do you see in your error log?

hi nkahr When I visit the route (which i set it by app.route) An error appears that say your site is busy or there is an error in your error log , I checked error log and see an error which said index.html did not find !! I use flask and template_render , and I put index.html in a folder which called templates

What is your code and what is directories structure?

My code is something like this (my telegram bot work perfectly but my home page does not work):

from flask import Flask , render_template
import telebot

app = Flask("MyApplication")

@app.route("/")
def home_page():
    return render_template("index.html")

@app.route("/webhook")
def handle_webhook():
    ... (Webhook setting , no issue)

bot_token = "*************************"
bot = telebot.TeleBot(bot_token)
bot.set_webhook("https://test.pythonanywhere.com/webhook")

That's it , There is no issue in bot codes , but when I want to visit https://test.pythonanywhere.com/ I get Internal server error

Look in your error log to find tracebacks that you can use to start debugging.

I find out that it uses 100% of cpu !!!! I do not know why it happen Can you please guide me ?

Web apps don't contribute to your CPU usage, so it must be something else.

I do not know why this happen , I am going to fix it

It's strange !! , when I go to my pythonanywhere account from mobile phone , the cpu usage is 0. but when I visited my account on my computer side , its usage was 124% !!! I do not really know what is happening :) Is it normal ?

Ok , cpu decreased to 0% (I do not know why it increased) , and I get new error in error log which say template index.html did not find , how can I solve this ? I put my index.html in a folder called templates

We need more details about your code and files location to help you. You may also look at other forum topics where people had similar problem.

I fixed it by defining template folder path in Flask() And now it can detect html file and load it ,but it can not use its css and js files , I am trying to solve it

All right , now it comes up without any issue, I define template folder in Flask("app name",template_folder="template folder full path") and in my html file I define my css and js file path like static/index.css ... Now it works Thanks

Great!