Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
15-437 Angular and Django
Search
ThierrySans
February 17, 2016
Programming
110
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
260
CSCD27 Web Security
thierrysans
0
450
CSCD27 Malicious Software
thierrysans
0
400
CSCD27 Protection
thierrysans
0
510
CSCD27 System Insecurity
thierrysans
0
440
CSCD27 Human Authentication
thierrysans
0
370
CSCD27 Network security
thierrysans
0
570
CSCD27 Network (in)security
thierrysans
0
560
CSCD27 Cryptography Protocols
thierrysans
0
720
Other Decks in Programming
See All in Programming
Observability in Practice:Grafana 與 Edge Device SRE 的那些事
blueswen
0
120
並列実装の現場、2ヶ月間実務でAIを使い倒したAIもPCも私も限界が近い
ming_ayami
0
110
ユニットテストの先へ:テスト技法で要求・仕様を整理するJava開発実践 / Beyond_Unit_Testing_Practical_Java_Development_Techniques_for_Organizing_Requirements_and_Specifications
shimashima35
0
350
AI 時代のソフトウェア設計の学び方
masuda220
PRO
29
12k
Spec Driven Development | AI Summit Lisbon
danielsogl
PRO
0
150
ローカルLLMを使ってB2Bサービスを作っていての学び
yaotti
0
140
Swiftのレキシカルスコープ管理
kntkymt
0
210
不変条件と整合性境界—ビジネスが決める設計判断と実現パターン / Invariants and Consistency Boundaries
nrslib
13
3.4k
プラグインで拡張される Context をtype-safe にする難しさと設計判断
kazupon
2
590
柔軟なPDFレイアウトエディタを支える型システム設計 — Discriminated UnionとConditional Typeの実践
minako__ph
4
1.4k
決定論的オーケストレーションの設計と実装 / Design and Implementation of Deterministic Orchestration
nrslib
3
1.1k
AI時代のUIはどこへ行く?その2!
yusukebe
19
6.7k
Featured
See All Featured
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.9k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.6k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.3k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
220
Practical Orchestrator
shlominoach
191
11k
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
1
250
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
55k
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
65
56k
How STYLIGHT went responsive
nonsquared
100
6.2k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.8k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
300
A designer walks into a library…
pauljervisheath
211
24k
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