Question

I'm starting with both web development and Python, so maybe I'm asking something stupid, but anyway. In PTVS where is only Django web project, however I would like to work with barebone WSGI Python web app as defined in PEP-0333. What should I do to setup a template for such app?

I guess I need to modify manage.py file to start some WSGI server, but I have absolutely no idea what I can possibly use.

In addition to Dino Viehland answer. You probably would want to use httpd.serve_forever() instead of httpd.handle_request().

Was it helpful?

Solution

We currently have no support for generic web frameworks... You're right that you'll just want to configure your project to launch the WSGI server. You can do that by right clicking on the project and going to properties and setting your startup script.

An easy way to get started with this would probably to use wsgiref.simple_server. You can then have a simple script which does something like what simple_server does if it's run as a script:

from wsgiref import simple_server
httpd = simple_server.make_server('', 8000, <your wsgi app here>)
sa = httpd.socket.getsockname()
print "Serving HTTP on", sa[0], "port", sa[1], "..."
import webbrowser
webbrowser.open('http://localhost:8000/xyz?abc')
httpd.handle_request()  # serve one request, then exit

For our 2.1 release we're looking at adding templates for a number of web frameworks as well as creating a generic web site project type which would probably work for you. If you have a particular framework you're using let us know as it'd help us prioritize which ones we pick.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top