SlideShare a Scribd company logo
SUSAN TAN
CISCO IN SAN FRANCISCO
TWITTER: @ARCTANSUSAN
HOW DO I RUN MULTIPLE PYTHON APPS
IN 1 COMMAND LINE UNDER 1 WSGI?
THIS IS A HELLO WORLD FLASK APP
from flask import Flask, request
app = Flask(__name__)
@app.route('/<name>')
def hello_world(name):
return "Hello %s, I'm a flask app!" % (name)
if __name__ == '__main__':
app.debug = True
app.run()
THIS IS A HELLO WORLD DJANGO APP
from django.http import HttpResponse
def hello(request, name):
return HttpResponse("<p>Hello, %s I'm a Django app.</p>" % (name,))
views.py
from django.conf.urls import patterns, include, url
urlpatterns = patterns('',
url(r'^(?P<name>[-w]+)/$', 'hello_django.mysite.myapp.views.hello'),
)
urls.py
Django app runs at http://127.0.0.1:8000/
Flask app runs at http://127.0.0.1:5000/
An Observation
HOW DO I COMBINE BOTH PYTHON APPS?
SO THEY’RE BOTH ON SAME PORT? SAME COMMAND LINE ?
WSGI DISPATCHER
Source: Reference: http://flask.pocoo.org/docs/0.10/patterns/appdispatch/
CONFIGURE WSGI.PY IN DJANGO APP
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE",
"hello_django.mysite.myapp.settings")
# This application object is used by any WSGI server
configured to use this
# file. This includes Django's development server, if
the WSGI_APPLICATION
# setting points here.
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
wsgi.py
THIS IS A HELLO WORLD COMBINED FLASK & DJANGO APP
from werkzeug.serving import run_simple
from werkzeug.wsgi import DispatcherMiddleware
import hello_flask
from hello_django.mysite.myapp import wsgi as hello_django
application = DispatcherMiddleware(hello_flask.app, {
'/django': hello_django.application
})
if __name__ == '__main__':
run_simple('localhost', 4000, application,
use_reloader=True, use_debugger=True, use_evalex=True)
combined_apps.py
How do I run multiple python apps in 1 command line under 1 WSGI app?
Let’s run more python web frameworks in 1
command line
LIVE DEMO TIME
Source Code?
https://github.com/ArcTanSusan/wsgi_lightnng_talk
Reference: http://flask.pocoo.org/docs/0.10/patterns/
appdispatch/
Slides? On slideshare. I tweeted them already.
Contact Info
Susan Tan
Twitter: @ArcTanSusan

More Related Content

PDF
Flask 소수전공 강의자료 - 1차시
ODP
Lets Get Started with Openshift
KEY
CoffeeScript: JavaScript, but Better!
PDF
Silex and Twig (PHP Dorset talk)
PPTX
Intro to Silex
PDF
Complex Sites with Silex
KEY
GLRB - Decent exposure
PDF
Open expo Novembre 2014
Flask 소수전공 강의자료 - 1차시
Lets Get Started with Openshift
CoffeeScript: JavaScript, but Better!
Silex and Twig (PHP Dorset talk)
Intro to Silex
Complex Sites with Silex
GLRB - Decent exposure
Open expo Novembre 2014

What's hot (12)

PDF
Yurii Bodarev - OTP, Phoenix & Ecto: Three Pillars of Elixir
PDF
Introduction to lua
PDF
PHP Programming: Intro
PPTX
23.simple login with sessions in laravel 5
DOCX
Harrigan_Danielle_Programming
PDF
Scratching the surface of hunky-dory Elixir features
KEY
次世代PHPフレームワーク Symfony2
ODP
UTAU DLL voicebank and ulauncher
PDF
PHP and Databases
PPT
You promise?
PDF
[Erlang LT] Regexp Perl And Port
DOC
Winefontssmoothing en
Yurii Bodarev - OTP, Phoenix & Ecto: Three Pillars of Elixir
Introduction to lua
PHP Programming: Intro
23.simple login with sessions in laravel 5
Harrigan_Danielle_Programming
Scratching the surface of hunky-dory Elixir features
次世代PHPフレームワーク Symfony2
UTAU DLL voicebank and ulauncher
PHP and Databases
You promise?
[Erlang LT] Regexp Perl And Port
Winefontssmoothing en
Ad

Viewers also liked (16)

DOCX
Garcia reyna luis angel
DOCX
Uso del internet
PDF
다이어트내비App 기획안
PPTX
Algas azuis
PDF
1rst ARCADIA project newsletter
PDF
Rfid tech for library | تحديد الهوية بموجات الراديو
PPTX
عرض الفصل 7 و8و9
PPTX
MoM2010: Steps to Patent Your Ideas
PPTX
Commibr4 الاتصال الفعال
PPTX
Consumption Smoothing and Productive Investments in Rural Zambia
PPTX
Protozoários sarcodina
PPTX
Driver based planning
PPTX
محاضرتي الثانية
PDF
ضبط الجودة النوعية فى المختبرات الطبية
PPTX
الجمعية الصحية الصومالية في الكويت
Garcia reyna luis angel
Uso del internet
다이어트내비App 기획안
Algas azuis
1rst ARCADIA project newsletter
Rfid tech for library | تحديد الهوية بموجات الراديو
عرض الفصل 7 و8و9
MoM2010: Steps to Patent Your Ideas
Commibr4 الاتصال الفعال
Consumption Smoothing and Productive Investments in Rural Zambia
Protozoários sarcodina
Driver based planning
محاضرتي الثانية
ضبط الجودة النوعية فى المختبرات الطبية
الجمعية الصحية الصومالية في الكويت
Ad

Similar to How do I run multiple python apps in 1 command line under 1 WSGI app? (20)

PPTX
PDF
Flask for cs students
PPTX
Python/Flask Presentation
PDF
Flask Introduction - Python Meetup
PDF
Kyiv.py #17 Flask talk
PDF
Python and Flask introduction for my classmates Презентация и введение в flask
PPTX
Flask-Python
PDF
Composing WSGI apps and spellchecking it all
PPTX
uWSGI - Swiss army knife for your Python web apps
PDF
Python Web Applications With Flask Handon Your Flask Skills2024 Jeffrey Leon ...
PDF
Multiple django applications on a single server with nginx
PDF
WSGI, Django, Gunicorn
PPTX
flask frameworkbasedonPython_microframework.pptx
PDF
Introduction to Flask Micro Framework
PPTX
Flask and Introduction to web frameworks
KEY
LvivPy - Flask in details
KEY
The story and tech of Read the Docs
PPTX
Intro to flask2
PPTX
Intro to flask
PPTX
How to write your first online programme in Python
Flask for cs students
Python/Flask Presentation
Flask Introduction - Python Meetup
Kyiv.py #17 Flask talk
Python and Flask introduction for my classmates Презентация и введение в flask
Flask-Python
Composing WSGI apps and spellchecking it all
uWSGI - Swiss army knife for your Python web apps
Python Web Applications With Flask Handon Your Flask Skills2024 Jeffrey Leon ...
Multiple django applications on a single server with nginx
WSGI, Django, Gunicorn
flask frameworkbasedonPython_microframework.pptx
Introduction to Flask Micro Framework
Flask and Introduction to web frameworks
LvivPy - Flask in details
The story and tech of Read the Docs
Intro to flask2
Intro to flask
How to write your first online programme in Python

More from Susan Tan (7)

PDF
Rants and Ruminations From A Job Applicant After 💯 CS Job Interviews in Silic...
PDF
Let's read code: python-requests library
PDF
How to Upgrade to the Newest Shiniest Django Version
PDF
Let's read code: the python-requests library
PDF
How to Really Get Git
PDF
Python In The Browser: Intro to Brython
PDF
How to choose an open-source project
Rants and Ruminations From A Job Applicant After 💯 CS Job Interviews in Silic...
Let's read code: python-requests library
How to Upgrade to the Newest Shiniest Django Version
Let's read code: the python-requests library
How to Really Get Git
Python In The Browser: Intro to Brython
How to choose an open-source project

Recently uploaded (20)

PDF
FINAL CALL-6th International Conference on Networks & IOT (NeTIOT 2025)
PPTX
Introduction about ICD -10 and ICD11 on 5.8.25.pptx
PPTX
innovation process that make everything different.pptx
PDF
💰 𝐔𝐊𝐓𝐈 𝐊𝐄𝐌𝐄𝐍𝐀𝐍𝐆𝐀𝐍 𝐊𝐈𝐏𝐄𝐑𝟒𝐃 𝐇𝐀𝐑𝐈 𝐈𝐍𝐈 𝟐𝟎𝟐𝟓 💰
PPTX
Introuction about WHO-FIC in ICD-10.pptx
PPTX
artificialintelligenceai1-copy-210604123353.pptx
PPT
Ethics in Information System - Management Information System
PPTX
E -tech empowerment technologies PowerPoint
PPTX
international classification of diseases ICD-10 review PPT.pptx
PPTX
INTERNET------BASICS-------UPDATED PPT PRESENTATION
PDF
Cloud-Scale Log Monitoring _ Datadog.pdf
PDF
Paper PDF World Game (s) Great Redesign.pdf
PPTX
Module 1 - Cyber Law and Ethics 101.pptx
PDF
The New Creative Director: How AI Tools for Social Media Content Creation Are...
PPT
FIRE PREVENTION AND CONTROL PLAN- LUS.FM.MQ.OM.UTM.PLN.00014.ppt
PDF
Unit-1 introduction to cyber security discuss about how to secure a system
PPTX
PptxGenJS_Demo_Chart_20250317130215833.pptx
PPTX
Digital Literacy And Online Safety on internet
PDF
Vigrab.top – Online Tool for Downloading and Converting Social Media Videos a...
PPTX
artificial intelligence overview of it and more
FINAL CALL-6th International Conference on Networks & IOT (NeTIOT 2025)
Introduction about ICD -10 and ICD11 on 5.8.25.pptx
innovation process that make everything different.pptx
💰 𝐔𝐊𝐓𝐈 𝐊𝐄𝐌𝐄𝐍𝐀𝐍𝐆𝐀𝐍 𝐊𝐈𝐏𝐄𝐑𝟒𝐃 𝐇𝐀𝐑𝐈 𝐈𝐍𝐈 𝟐𝟎𝟐𝟓 💰
Introuction about WHO-FIC in ICD-10.pptx
artificialintelligenceai1-copy-210604123353.pptx
Ethics in Information System - Management Information System
E -tech empowerment technologies PowerPoint
international classification of diseases ICD-10 review PPT.pptx
INTERNET------BASICS-------UPDATED PPT PRESENTATION
Cloud-Scale Log Monitoring _ Datadog.pdf
Paper PDF World Game (s) Great Redesign.pdf
Module 1 - Cyber Law and Ethics 101.pptx
The New Creative Director: How AI Tools for Social Media Content Creation Are...
FIRE PREVENTION AND CONTROL PLAN- LUS.FM.MQ.OM.UTM.PLN.00014.ppt
Unit-1 introduction to cyber security discuss about how to secure a system
PptxGenJS_Demo_Chart_20250317130215833.pptx
Digital Literacy And Online Safety on internet
Vigrab.top – Online Tool for Downloading and Converting Social Media Videos a...
artificial intelligence overview of it and more

How do I run multiple python apps in 1 command line under 1 WSGI app?

  • 1. SUSAN TAN CISCO IN SAN FRANCISCO TWITTER: @ARCTANSUSAN HOW DO I RUN MULTIPLE PYTHON APPS IN 1 COMMAND LINE UNDER 1 WSGI?
  • 2. THIS IS A HELLO WORLD FLASK APP from flask import Flask, request app = Flask(__name__) @app.route('/<name>') def hello_world(name): return "Hello %s, I'm a flask app!" % (name) if __name__ == '__main__': app.debug = True app.run()
  • 3. THIS IS A HELLO WORLD DJANGO APP from django.http import HttpResponse def hello(request, name): return HttpResponse("<p>Hello, %s I'm a Django app.</p>" % (name,)) views.py from django.conf.urls import patterns, include, url urlpatterns = patterns('', url(r'^(?P<name>[-w]+)/$', 'hello_django.mysite.myapp.views.hello'), ) urls.py
  • 4. Django app runs at http://127.0.0.1:8000/ Flask app runs at http://127.0.0.1:5000/ An Observation HOW DO I COMBINE BOTH PYTHON APPS? SO THEY’RE BOTH ON SAME PORT? SAME COMMAND LINE ?
  • 7. CONFIGURE WSGI.PY IN DJANGO APP import os os.environ.setdefault("DJANGO_SETTINGS_MODULE", "hello_django.mysite.myapp.settings") # This application object is used by any WSGI server configured to use this # file. This includes Django's development server, if the WSGI_APPLICATION # setting points here. from django.core.wsgi import get_wsgi_application application = get_wsgi_application() wsgi.py
  • 8. THIS IS A HELLO WORLD COMBINED FLASK & DJANGO APP from werkzeug.serving import run_simple from werkzeug.wsgi import DispatcherMiddleware import hello_flask from hello_django.mysite.myapp import wsgi as hello_django application = DispatcherMiddleware(hello_flask.app, { '/django': hello_django.application }) if __name__ == '__main__': run_simple('localhost', 4000, application, use_reloader=True, use_debugger=True, use_evalex=True) combined_apps.py
  • 10. Let’s run more python web frameworks in 1 command line LIVE DEMO TIME