Successfully reported this slideshow.
Your SlideShare is downloading. ×

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

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Loading in …3
×

Check these out next

1 of 11 Ad

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

Download to read offline

You build a Django app and run "python manage.py runserver" to test it locally. You build a Flask app and run "python hello_flask.py". You build a pyramid app and run "python hello_pyramid.py". What if you can run all these Python web frameworks in 1 command line instead?

You build a Django app and run "python manage.py runserver" to test it locally. You build a Flask app and run "python hello_flask.py". You build a pyramid app and run "python hello_pyramid.py". What if you can run all these Python web frameworks in 1 command line instead?

Advertisement
Advertisement

More Related Content

Viewers also liked (16)

Advertisement

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

Advertisement

Recently uploaded (20)

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

  1. 1. SUSAN TAN CISCO IN SAN FRANCISCO TWITTER: @ARCTANSUSAN HOW DO I RUN MULTIPLE PYTHON APPS IN 1 COMMAND LINE UNDER 1 WSGI?
  2. 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. 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. 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 ?
  5. 5. WSGI DISPATCHER
  6. 6. Source: Reference: http://flask.pocoo.org/docs/0.10/patterns/appdispatch/
  7. 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. 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
  9. 9. Let’s run more python web frameworks in 1 command line LIVE DEMO TIME
  10. 10. 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

×