Python on websites

Associate
Joined
10 Dec 2007
Posts
1,943
Location
SE
I've been playing around with Python for a few months now, 99% of the time through the Python IDE or using Pycharm. I've used it to muck around with some API's (most notably one that queries IMDB; you put in the title of the film and it returns a description, rating, year etc.) but I can't for the life of me figure out how to get this data from the output in the IDE to a website.

I've been exploring Django and Flask (albeit just for a few hours) but it's just not clicking how I would get my experience of using Python into a website (I know quite a bit of HTML, CSS and some Javascript).

I've been googling for ages and I'm now going around in circles.

If anyone can point me in the right direction, I'd be very grateful.

Thanks
 
Soldato
Joined
25 Jun 2011
Posts
5,468
Location
Yorkshire and proud of it!
I've been playing around with Python for a few months now, 99% of the time through the Python IDE or using Pycharm. I've used it to muck around with some API's (most notably one that queries IMDB; you put in the title of the film and it returns a description, rating, year etc.) but I can't for the life of me figure out how to get this data from the output in the IDE to a website.

I've been exploring Django and Flask (albeit just for a few hours) but it's just not clicking how I would get my experience of using Python into a website (I know quite a bit of HTML, CSS and some Javascript).

I've been googling for ages and I'm now going around in circles.

If anyone can point me in the right direction, I'd be very grateful.

Thanks

You need to settle on a web server. Apache is old and tested and the Django installation documentation talks you through how to configure Apache to server your Django application. Nginx is more trendy these days but there's no particular reason to use it over Apache if you're just trying out development of your site. If you're on Windows then you'll almost certainly want to use IIS, which comes with Windows in-built but will have to be enabled. However, as you specifically mention Django you can skip this for now. Django comes with a built in web server suitable for development purposes (it wouldn't scale for high-volume real world usage). When you start the Django application as per the tutorial, it should specify a port number that it's listening on. By default this will be 8000 iirc. Which would mean you'd enter http://127.0.0.1:8000 in your browser and hopefully see your Django application's default interface. (127.0.0.1 is your computers home address, always. :8000 means listen on port 8000 which is different to the default for HTTP).

When you're ready to go beyond that for real world usage, you'll need to configure a web server to serve the Django application rather than running its inbuilt one. If you want to run a Python application other than Django, then you'll need to look at specific instructions for that application. If it's entirely your own application, you'll need to configure a plug in for the webserver that knows how to execute Python or make your application handle web responses itself. I would start with running Django in a website first.
 
Back
Top Bottom