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
120
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
15-437 Angular and Django
ThierrySans
February 17, 2016
More Decks by ThierrySans
See All by ThierrySans
CSCD27 Social Engineering
thierrysans
0
270
CSCD27 Web Security
thierrysans
0
460
CSCD27 Malicious Software
thierrysans
0
410
CSCD27 Protection
thierrysans
0
520
CSCD27 System Insecurity
thierrysans
0
450
CSCD27 Human Authentication
thierrysans
0
370
CSCD27 Network security
thierrysans
0
580
CSCD27 Network (in)security
thierrysans
0
570
CSCD27 Cryptography Protocols
thierrysans
0
740
Other Decks in Programming
See All in Programming
20260828_品質と開発生産性を両立させる、AI時代のE2Eテストの考え方
magicpod
0
210
【DroidKaigi 2026】「アクセシビリティを利用するとき、 アクセシビリティもまたこちらを利用している」 〜マルウェアによる攻撃と防衛について〜
halunoyo
0
460
Omarchy Tokyo やると聞いて UMPC 買ってセットアップしてきた
mtsmfm
0
140
DroidKaigi 2026 「個人開発という実験場: Android エンジニアが手にする4つの自由」
slashnephy
0
230
Vibes Containers 〜AIで変わるコンテナ設計と運用〜
tkikuc
3
550
新卒PdEのリアル
ryu1013
1
500
Are APIs Still Relevant in the AI Era?
soyuka
0
220
Claude Codeを組織的に動かして月400PRを実現した話
happy_ryo
0
280
cdk deploy JawsSonic #MARATHONしながらAWSリソースをデプロイしてみよう
akihisaikeda
2
130
WebRTC映像をAirPlayに対応させる挑戦.pdf
monolithic_adam
0
260
Java 27新機能 / Java 27 new features
kishida
2
140
What We Talk About When We Talk About XP
m_seki
2
620
Featured
See All Featured
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.8k
The SEO identity crisis: Don't let AI make you average
varn
0
560
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
203
76k
Designing for Performance
lara
611
70k
The Curse of the Amulet
leimatthew05
3
14k
Un-Boring Meetings
codingconduct
0
420
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.2k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.6k
Designing Experiences People Love
moore
143
24k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2.2k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.8k
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Transcript
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