0

I am attempting to make a dynamic website for a school project. The problem is it has to be on the school server and I can't use any webframeworks. I have searched through google and stackoverflow but I can't seem to get an answer. I have tried the code that was provided here: How to implement a minimal server for AJAX in Python? It worked on the local server but how can I change it so that it would open on the school server. When I used those codes, the page won't load or an internal error shows. Can someone point me in the right direction?

Community
  • 1
  • 1
dismal
  • 21
  • 1
  • 1
  • 5
  • What is it running with? CGI? WSGI? You can most likely use [Bottle](http://bottlepy.org/docs/dev/), as it's a single Python file that you just import: http://bottlepy.org/docs/dev/ – Blender Jun 09 '13 at 22:25
  • What is restricting you from using a web framework? Basically all python frameworks are just folders of python files, much like one of your projects would be. – korylprince Jun 09 '13 at 22:36
  • Your question seems a bit unclear but if I understand you correctly, this is what you might be looking for - [add CORS support to server](http://enable-cors.org/server.html) – Simon K Bhatta4ya Sep 23 '13 at 04:10

1 Answers1

0

Using a web framework in python does not necessary needs a system package installation (like running a sudo apt-get install python-something).

In the end python frameworks are just files like in your project, but you can install them system wide (like in the apt-get example) or ship them within your project (probably what you want). Take a look at virtual environment for creating a self contained environment and setuptools foi packaging the application and its dependencies

For implementing an ajax server directly in python without a wsgi container (apache, nginx, etc) I recommend using flask. It is very, very simple and very powerful

Bruno Penteado
  • 2,234
  • 2
  • 23
  • 26
  • So how would the server be running? Does the person for instance have to click on the python file that starts the server and then navigate to the website or do I have to keep the python file running at all times? I am just beginning to learn about response back to ajax, so some of the basic concepts i haven't grasped yet. – dismal Jun 09 '13 at 23:31
  • You start the server and leave it running untill you dont want to attend requests anymore. Every server in the end has an infinite loop awaiting for requests somewhere inside it. The basic dispatch mechanism is waiting for socket connections and when they arrive (a HTTP request for instance), start a process/thread to attend it (the dispatch action) and go back to wait on a new connection on the socket – Bruno Penteado Jun 09 '13 at 23:39
  • So how would you recommend doing that while being on the school server? – dismal Jun 09 '13 at 23:44
  • Just start the script in the server like you started in your computer (i hope for the sake of simplicity that you are both on the same operational system). Remember that accessing a resource remotely (your browser -> school server) instead of locally (your browser -> your machine) you can pass by the internet (that should not be a problem) and also your python script has to bind to the lan/wan IP of the server. If your script is binding on 127.0.0.1, you cant access it from an external machine. Try to make it bind on 0.0.0.0 (all interfaces) – Bruno Penteado Jun 09 '13 at 23:53
  • Also, remember that addresses like 'http://something.org/thing' will try to access the port 80 of the server while 'http://something.org:8080/thing' will try to access the 8080 port. IF you are struggling with http and server connections, try reading [this](http://www.ntu.edu.sg/home/ehchua/programming/webprogramming/HTTP_Basics.html), it explains how http works – Bruno Penteado Jun 09 '13 at 23:57