Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
15-437 Angular and Django
Search
ThierrySans
February 17, 2016
Programming
130
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
15-437 Angular and Django
ThierrySans
February 17, 2016
Transcript
19 slides
Angular and Django Thierry Sans
Create a project $ django-admin.py startproject webgallery
Summary URLs Served by Django / statically /static/* statically /api/*
dynamically
1. serving / statically
1.1 import index.html webgallery/ manage.py index.html webgallery/ __init__.py settings.py urls.py
wsgi.py
1.2 Configure webgallery/urls.py from django.conf import settings from django.views.static import
server if settings.DEBUG: urlpatterns += [url(r'^(?:index.html)?$', serve, {'path': 'index.html','document_root': settings.BASE_DIR})] webgallery/urls.py
1.3 Test localhost:8000/ You should see your index page But
lot of errors : resources (css, js, …) cannot be found
2. serving /static/* statically
1.1 import all static files in /static/ webgallery/ manage.py
index.html webgallery/ __init__.py settings.py urls.py wsgi.py static/ app/ includes/ media/ style/ ...
2.2 configure settings.py to serve /static/ files webgallery/settings.py #
Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.9/howto/static-files/ STATIC_URL = '/static/' STATICFILES_DIRS = [os.path.join(BASE_DIR, “static")]
2.3 Test resources You should see resources such as •
localhost:8000/static/style/style.css • localhost:8000/static/app/webgallery.js • ...
2.4 Update your fronted ➡ You should remove all errors
by modifying the path of resources
3. serving /api/* dynamically
3.1 Create an app called api • Create the app
$ python manage.py startapp api • Configure webgallery/settings.py # Application definition INSTALLED_APPS = ( 'django.contrib.admin', ... 'django.contrib.staticfiles', 'api' )
3.2 Configure the url dispatchers • webgallery project URL dispatcher
• api app url dispatcher from django.conf.urls import url from . import views urlpatterns = [ url(r'^helloworld/$', views.helloWorld, name='helloWorld'), url(r'^img/(?P<id>\w+)/$', views.getImgInfo,name='getImgInfo')] api/urls.py webgallery/urls.py from django.conf.urls import include, url urlpatterns += [url(r'^api/', include(‘api’))]
3.3 Write the services from django.shortcuts import render # Create
your views here. from django.http import JsonResponse def helloWorld(request): response = JsonResponse("helloworld",safe=False) return response def getImageInfo(request,id): print id response = JsonResponse(id,safe=False) return response api/views.py
3.5 Test services You should see the services such as
• localhost:8000/api/helloworld/ • localhost:8000/api/img/23/ • ...
4. Complete the API
5. Interface the frontend with the API
More Decks by ThierrySans
See All by ThierrySans
CSCD27 Social Engineering
thierrysans
0
280
CSCD27 Web Security
thierrysans
0
480
CSCD27 Malicious Software
thierrysans
0
430
CSCD27 Protection
thierrysans
0
530
CSCD27 System Insecurity
thierrysans
0
490
CSCD27 Human Authentication
thierrysans
0
380
CSCD27 Network security
thierrysans
0
600
CSCD27 Network (in)security
thierrysans
0
580
CSCD27 Cryptography Protocols
thierrysans
0
760
Other Decks in Programming
See All in Programming
Snowflake Openflow Connector利用の勘所 / 20261024developersio2026tokyo-snowflake-openflow
kasacchiful
PRO
0
350
SODA - FACT BOOK(EN)
sodainc
1
260
imagewebp()の向こう側: WebPはなぜ JPEG・PNGより軽いのか
yuzneri
0
130
Engineering Biometric UX Across Android Versions | DroidKnights 2026
ryunen344
1
210
Claude Codeのおかげでやりたいことがやれるようになったんだよォー!
sms_tech
0
140
Rails初心者がパスキーを実装してみて大変だったこと
ktombow
0
210
地方こそサーバーレス — 10年続けた、顔が見えるチームで確かな基盤を / Serverless Matters Most in Regional Areas — 10 Years of Building Reliable Foundations with Close-Knit Teams
seike460
PRO
2
490
Proxmox x Talos Linux x Terraform で実現するなんかいい感じの Kubernetes クラスタ / A Sleek Kubernetes Cluster Powered by Proxmox, Talos Linux, and Terraform
nnaka2992
0
250
はじめてのPLATEAU
nokonoko1203
1
660
TanStack Vue Query と Pinia Colada から学ぶ非同期状態の型設計
aoshi
0
690
ビジネスロジックを堅牢に~Scala 3のドメインプリミティブ~
j5ik2o
0
200
AIがコードを書いてくれる時代、我々は何を確かめるのか
yosuke_furukawa
PRO
13
6.1k
Featured
See All Featured
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
630
Mobile First: as difficult as doing things right
swwweet
225
10k
The browser strikes back
jonoalderson
0
2k
The Curious Case for Waylosing
cassininazir
1
610
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.4k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.6k
Accessibility Awareness
sabderemane
1
300
Reflections from 52 weeks, 52 projects
jeffersonlam
356
22k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.8k
The SEO identity crisis: Don't let AI make you average
varn
0
630
Color Theory Basics | Prateek | Gurzu
gurzu
1
530