Skip to content

Instantly share code, notes, and snippets.

View SazanDawadi's full-sized avatar
😇

Sajan Dawadi SazanDawadi

😇
  • Kathmandu
View GitHub Profile
// importing http
const http = require('http');
# firstapp/views.py
from django.shortcuts import render
def hello(request):
context = {}
return render(request, 'firstapp/index.html', context)
<!--File path: templates/firstapp/index.html -->
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<title>Hello world webapp</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
/* file path: mysite/static/css/main.css */
body {
font-family: Arial;
background: #1abc9c;
margin: 0;
}
.header {
text-align: center;
<!--File path: templates/firstapp/index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<title>Hello world webapp</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
# mysite/urls.py
from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path('', include('firstapp.urls')),
path('admin/', admin.site.urls),
]
@SazanDawadi
SazanDawadi / urls.py
Last active August 3, 2020 12:25
create your url
#File path: firstapp/urls.py
from django.urls import path
from . import views
urlpatterns = [
path('', views.hello, name='hello'),
]
@SazanDawadi
SazanDawadi / first_views.py
Last active August 2, 2020 15:21
Create your first view
# firstapp/views.py
from django.http import HttpResponse
def hello(request):
return HttpResponse("Hello world")