This is a simple Django application that returns a "Hello World" message in both JSON and HTML formats.
- A single route (
/hello/
) that returns either:- A JSON response:
{"Message": "Hello World!"}
- An HTML page with "Hello World!" in bold.
- A JSON response:
- Python 3.0
- Django (Version 3.0 or above)
git clone https://github.com/Kur0iTsuki/helloworld_django
cd helloworld_django
cd helloworld_project
- Set Up a Virtual Environment (Optional but recommended)
python -m venv env
source env/bin/activate # On Windows use: env\Scripts\activate
3.Install Django
pip install django
4.Run the Django Development Server
python manage.py runserver
5.Access the App To access the JSON response, visit:
http://127.0.0.1:8000/hello/?format=json
output
{"Message": "Hello World!"}
To view the HTML response, visit:
http://127.0.0.1:8000/hello/