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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
Vapor Mode でアクセシビリティは 壊れないか検証した話
fuqda
1
350
自作Discord音声botをLambda MicroVMsに移行した話 / Migrating My Discord Voice Bot to Lambda MicroVMs
akihisaikeda
1
370
Enforcing Your Architecture with Unit Tests in the AI Era (Swift Connection X)
steliosf
PRO
1
190
DroidKnights 2026 Android A2UI Jetpack Compose 기반의 안전한 AI UI 렌더링 - 박제창
itsmedreamwalker
1
250
[Kotlin Fest 2026] eBPF Tracing for Kotlin
takehaya
1
330
TS 7.0 で baseUrl が使えなくなった今、パスエイリアスをどうするか
bicstone
2
720
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
370
flutter_test のその先へ — Flutter アプリの LLM 機能に「評価」という品質保証を
kosukesaigusa
0
200
動画プレイヤーはなぜカクつくのか 〜Flutterのレンダリングとネイティブの境界を解剖する〜
naruogram
0
340
小さなアプリを作って公開するまで
onozaty
0
200
はじめてのPLATEAU
nokonoko1203
1
660
エラーチャンネルのボールを拾い続けて鍛えるエンジニアの地力 / phpcon-niigata2026
meihei3
1
440
Featured
See All Featured
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.9k
Side Projects
sachag
456
43k
GitHub's CSS Performance
jonrohan
1033
470k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
340
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
2
530
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
Building Flexible Design Systems
yeseniaperezcruz
330
41k
Speed Design
sergeychernyshev
33
2.2k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.9k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
980