Using Flask
Flask is a micro-framework for Python, meaning it’s lightweight and easy to use for small to medium-sized applications.
- Install Flask: bash- pip install Flask
- Create a basic Flask application: python- from flask import Flask app = Flask(__name__) @app.route('/') def home(): return "Hello, Flask!" if __name__ == "__main__": app.run(debug=True)
- Run the application: Save the file (e.g., - app.py), then run it from the command line:bash- python app.py
- View the website: Open your browser and go to - http://127.0.0.1:5000/to see your "Hello, Flask!" message.
Using Django
Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design.
- Install Django: bash- pip install Django
- Create a Django project: bash- django-admin startproject myproject cd myproject
- Create a Django app: bash- python manage.py startapp myapp
- Define a view in - myapp/views.py:python- from django.http import HttpResponse def home(request): return HttpResponse("Hello, Django!")
- Configure the URL in - myproject/urls.py:python- from django.contrib import admin from django.urls import path from myapp import views urlpatterns = [ path('admin/', admin.site.urls), path('', views.home), ]
- Run the development server: bash- python manage.py runserver
- View the website: Open your browser and go to - http://127.0.0.1:8000/to see your "Hello, Django!" message.
Additional Steps
For both frameworks, you can further develop your website by:
- Adding templates: HTML files that define the structure of your web pages.
- Adding static files: CSS, JavaScript, and image files to style and add interactivity to your website.
- Creating models: Define your data structure and interact with the database.
- Implementing forms: Handle user input and submissions.

.png)
 
 
 
.png) 
0 Comments