Get in touch: support@brackets-hub.com



Basic “Hello, World!” application using Django and Ruby on Rails.

Django Example:

  1. Install Django (if not already installed):
pip install django
  1. Create a new Django project:
django-admin startproject hello_django
  1. Change directory to the newly created project:
cd hello_django
  1. Create a new Django app:
python manage.py startapp hello_app
  1. Open hello_app/views.py and add the following code:
from django.http import HttpResponse

def hello(request):
    return HttpResponse("Hello, Django!")
  1. Open hello_django/urls.py and add the following code:
from django.urls import path
from hello_app import views

urlpatterns = [
    path('', views.hello, name='hello'),
]
  1. Run the Django development server:
python manage.py runserver
  1. Open your web browser and navigate to http://localhost:8000 to see the “Hello, Django!” message.

Ruby on Rails Example:

  1. Install Ruby on Rails (if not already installed):
gem install rails
  1. Create a new Rails application:
rails new hello_rails
  1. Change directory to the newly created application:
cd hello_rails
  1. Generate a new controller and view:
rails generate controller welcome hello
  1. Open app/controllers/welcome_controller.rb and add the following code:
class WelcomeController < ApplicationController
  def hello
  end
end
  1. Open app/views/welcome/hello.html.erb and add the following code:
<h1>Hello, Rails!</h1>
  1. Open config/routes.rb and add the following code:
Rails.application.routes.draw do
  get 'welcome/hello'
  root 'welcome#hello'
end
  1. Run the Rails server:
rails server
  1. Open your web browser and navigate to http://localhost:3000 to see the “Hello, Rails!” message.

These examples demonstrate the basic setup and structure of a “Hello, World!” application using Django and Ruby on Rails. You can further explore these frameworks to build more complex web applications.

Leave a Reply

Your email address will not be published. Required fields are marked *