top of page
Search

Create a basic websites:-

  • Writer: dipeshbakhrel
    dipeshbakhrel
  • Nov 9, 2024
  • 1 min read

Sure, here's a simple Python script using the Flask framework to create a basic website:

from flask import Flask, render_template

python

Copy code


from flask import Flask, render_template:-


app = Flask(__name__)


@app.route('/')

def index():

    return render_template('index.html')


if name == '__main__':

    app.run(debug=True)


This script sets up a basic Flask application with one route ('/') that renders an HTML template called 'index.html'. You'll need to create the 'index.html' file in a folder called 'templates' in the same directory as your Python script.


Here's a basic 'index.html' file you can start with:


html

Copy code

   

   

   

   

Welcome to My Website

   

This is a basic website created using Python and Flask.


Save this code in a file named 'index.html' inside a folder named 'templates' in the same directory as your Python script.


To run this script, make sure you have Flask installed (pip install flask), then you can run the script and visit

 
 
 

Comments


bottom of page