Creating My First Django Application Part 2

python manage.py runserver

Creating View

from django.shortcuts import render
from django.http import HttpResponse
# Create your views here.
def hello(request):
text=”<h1>This is my first Application</h1>”
return HttpResponse(text)

URL Mapping

from django.contrib import admin
from django.urls import path
from myapp import views
urlpatterns = [
path(‘hello/’,views.hello)
]
Our First Html Page

Render HTML files in views

<HTML><HEAD>
<TITLE>This is a Sample Django Application</TITLE>
</HEAD><BODY BGCOLOR=”FFFFFF”>
<HR>
<a href=”http://gtu.ac.in">Link Name</a>
is a link to another nifty site
<H1>This is a Header</H1>
<H2>This is a Medium Header</H2>
Send me mail at <a href=”nareshkr.22@gmail.com”>
nareshkr.22@gmail.com</a>.
<P> This is a new paragraph!
<P> <B>This is a new paragraph!</B>
<BR> <B><I>This is a new sentence without a paragraph break, in bold italics.</I></B>
<HR>
</BODY>
</HTML>
views.py
urls.py
Flow of our Request
Sample Output

References

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store