Ask coding questions

← Back to all posts
Python Webpage
MrBigJuicyGrap3 (0)

Hi, I'm currently hosting a bot using repl. I was wondering if there was a way to add html to the webpage it creates(the one you use on uptime robot)

Answered by FishballNooodle (211) [earned 5 cycles]
View Answer
Comments
hotnewtop
FishballNooodle (211)

Create a templates folder
Add index.html
Go to Line 1 of keep_alive.py
Change to from flask import Flask,render_template
Go to Line 8 of keep_alive.py
change to return render_template("index.html")
To add css:
Create static folder
Add style.css inside

MrBigJuicyGrap3 (0)

@FishballNooodle is the static folder inside the templates folder, or outisde?

MrBigJuicyGrap3 (0)

@VulcanWM so then how do i link my css to html (im new to html), cuz when i just put in style.css it dont work

MrBigJuicyGrap3 (0)

@VulcanWM how do i link them if style.css is in a whole other folder?

VulcanWM (2886)

You can name the static folder something else and mention that when creating the Flask app @MrBigJuicyGrap3

MrBigJuicyGrap3 (0)

@VulcanWM i figured out that if you put a ../static/style.css, it works cause the .. means to leave the folder index.html is in

CosmicBear (45)

@MrBigJuicyGrap3 put this <link rel="stylesheet" href="/static/style.css"> In your HTML template

MrBigJuicyGrap3 (0)

@CosmicBear i put a .. infront on /staic/style.css and it left the folder and went to the new one :)

CosmicBear (45)

use Flask's render_template function

Coder100 (18882)

using flask you can render html and create backend for websites.
check it out!
https://www.tutorialspoint.com/flask/index.htm