I have successfully run the simplest pyramid app in my local virtual environment. I am now working on this tutorial but I am trying to take it a step further by running it on my personal hosting site that I use to mess around with stuff like this.
My question is. What do I pass to make_server(host, port, app)
as parameters and what url do I go to to check to see if it is running? I know it's a simple question, I'm just not used to this kind of work and the documentation isn't helping me.
Bonus Points:
What are the differences between running this on a local virtual environment and on proper hosting in terms of this kind of web application?
important edit: my provider is bluehost and since I don't have a dedicated IP, I am not allowed to open my own ports, which makes me wonder if this is even possible
In fact, hosting a Python application on a "real" webserver is quite different from running it on you local machine: locally you rely on a small webserver which is often built into the framework - however, that webserver often has limitations (for example, it may only execute requests in a single thread). Some frameworks (Django) explicitly state that their built-in server should only be used for development.
In a production environment a Python application is usually served by a "industrial-grade" webserver, such as Apache or Nginx, which takes care of such issues as binding to low ports, dropping privileges, spawning multiple "worker" processes, dealing with virtual hosts, sanitizing malformed requests etc. The Python application is then run within the web server using something like mod_wsgi
or fcgi
for Apache or uwsgi
for Nginx. Alternatively, your application runs as a separate process listening on 127.0.0.1:6543 (just like you do it locally) and the "front" web server proxies all requests to your application and back.
The point is: It may be tricky/impossible to host a Python application on a general purpose shared hosting unless your provider has explicit support for hosting WSGI applications (ask them for instructions)
Another point: for $5/mo these days you can get a nice dedicated virtual machine where you can install whatever your want and not share it with anyone. Hosting a Python website is much easier this way then dealing with shared hosting.
Ahh, and to answer the question: in a real production application the last 2 lines of the example:
server = make_server('0.0.0.0', 8080, app)
server.serve_forever()
will not be used - instead you configure the webserver so it knows that the app
variable contains your wsgi application. Refer to the next chapter in the docs for a more realistic example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With