Python has a solid set tools to power web applications. The necessary knowledge lies in passing variables between python and jquery, however this can be hard to figure out. Here is a simple tutorial on how to send information between python and jquery to make python-powered web applications.
1. Write the HTML
<!DOCTYPE html> <head> <meta http-equiv="content-type" content="text/html;charset=UTF-8"> <title>Python-jQuery Example</title> <script src="http://code.jquery.com/jquery-1.5.js"></script> </head> <body> <center> <h2>Python-jQuery Example</h2> <form id="search_box"><input id="search_text" type="text"/></form> <br/> <div id="jQuery_send"></div> <div id="python_response"></div> </center> </body> </html>
2. Write the jQuery Script
<script> $('#search_box').submit(function() { $('#jQuery_send').text("jQuery sent: " + $('#search_text').val() ); $.ajax( { type: "POST", url: "../cgi-bin/test.py", data: "stuff_for_python=" + $('#search_text').val(), success: function(response) { $('#python_response').text("Python returned: " + response); } }); return false; }); </script>Note: If you are testing this on an OSX, place the html file in /Library/Webserver/Documents/.
3. Write the python script
#!/usr/bin/python import cgi, cgitb cgitb.enable() # for troubleshooting #the cgi library gets vars from html form = cgi.FieldStorage() jquery_input = form.getvalue("stuff_for_python", "nothing sent") #the next 2 'print' statements are important for web print "Content-type: text/html" print #this is the actual output print jquery_inputNote: Name the python script test.py. If you are testing this on an OSX, place the python script in /Library/Webserver/CGI-Executables/ (this is the cgi-bin).
References:
Ernest Ramirez is a PhD student at the UCSD Center for Wireless Health Systems. Apart from designing new ways to keep people healthy, he has redesigned his own office into a body and mind workout station. Literally 6 feet away from my desk, he has set up a treadmill so that he says fit while doing his research. There are some cool things going on at UCSD’s CalIt2, but Ernesto and his active desk really stand out. He’s new to Tumblr, so if you are interested in the latest intersections between health and technology, I strongly recommend following him!
wellovations: Two and half years ago I took the plunge and went out an bought a treadmill. Not for exercise, not to run indoors. No, I bought a treadmill to work. Yes, that’s right. I bought a treadmill for work. I have done a lot of research and long ago decided that this was not just a good idea, it was a must-do idea. So after trading one crisp clean Benjamin for a older model treadmill, convincing my parents that I needed their extra desk, and whipping out the few tools I have I was able to build my treadmill desk. What is a treadmill desk? Well…
(Source: wellovations)
The addition of the proposed modifications to the Research Plan has been done in such a way as to be very confusing. — UCSD IRB
New prototype for a stimulus trigger board with fiber optic delivery triggers to check the monitor for the exact time the stimulus was displayed. I love my job.
[video]
It followed from the special theory of relativity that mass and energy are both a different manifestation of the same thing […] and very small amounts of mass may be converted into a very large amount of energy. — Albert Einstien (Audio http://bit.ly/gHIDBr)
“Nobody understands quantum mechanics.” -Richard Feynman
To preface, I want to make a note that an understanding of the electronic structure of the atom, requires an understanding of elementary quantum mechanics, and therefore falls more heavily within the domain of physics than general chemistry. Most textbooks simply state that there are four quantum numbers, and expect you to memorize them. If you agree with that method, stop reading, else take note of Richard Feynman’s words and read on.
The idea of quantum mechanics started with Max Plank (circa 1900), who wanted to understand more about how heat is converted into light. Although he knew energy emitted from a radiating black body was proportional to the fourth power of the temperature of the black body (Stefan-Boltzmann Law), and that the temperature was proportional to color (Wien’s Displacement Law). The problem was that the exact emission spectrum observed was not properly accounted for by the combination of these theories, and in fact, this discrepancy bothered and confused physicists so much that the problem is called the “ultraviolet catastrophe.”
![]()
To solve the problem, he made a model predicated on a few assumptions:
Boom! There it is, the fundamental idea behind quantum mechanics. Now you know why electrons don’t exist between levels…because then Max Plank wouldn’t have a job. Also, this explains how energy of an electron is calculated. The farther it is from the nucleus, the more potential energy it wants to release by returning back to the lowest shell. If that shell is occupied, then it retains its PE and has an energy corresponding to the shell number where it resides ( E(n) = nhf ).
Real life Star Wars.
Laser Towards Milky Ways Center.
The color of the laser is precisely tuned to energize a layer of sodium atoms found in one of the upper layers of the atmosphere — one can recognize the familiar color of sodium street lamps in the color of the laser.This layer of sodium atoms is thought to be a leftover from meteorites entering the Earth’s atmosphere. When excited by the light from the laser, the atoms start glowing, forming a small bright spot that can be used as an artificial reference star for the adaptive optics. Using this technique, astronomers can obtain sharper observations. For example, when looking towards the center of our Milky Way, researchers can better monitor the galactic core, where a central super massive black hole, surrounded by closely orbiting stars, is swallowing gas and dust.
Taken with a wide angle lens, this photo covers about 180° of the sky.
(via scientistintraining)
[video]
Shigeru Kobayashi lives in Japan and has experienced the tsunami and nuclear power plant tragedy first-hand. Shigeru wanted a way that he could monitor the radiation levels at his home and compare them to other regions. So he bought a SparkFun Geiger counter and mated it to an Arduino board and a wireless LAN converter. He then interfaced the counter with Pachube.
This is an excellent example of how Arduino is changing our world by giving the ability to collect raw data, straight to developers and end users. Great job Shigeru!
The graph below is real time, and shows his LIVE geiger counts per minute (cpm) via Pachube’s embadable graph feature. (Hit refresh in your browser to see if it updated).

Shigeru’s Tutorial: http://www.yapan.org/main/2011/03/measure_radiation_dose.htmlLive Data: http://www.pachube.com/feeds/21508
Ps. This donation is for you man!

Doctors at Sunnybrook hospital in Toronto, Canada have taken interactive gaming to the next level when they hooked up a Kinect console to their medical imaging computer. Now when in the operating room, doctors can have direct access to MRI scans, without having to disinfect, leave the operating room, consult the scans, and then scrub back in. This hack allows them to virtually manipulate the scans and retrieve the necessary information by pulling it up on screen with a wave of their hand.
Toronto doctors hack a Kinect and hook it up to their medical imaging computer, giving them direct access to MRI scans in the operating room.
http://www.psfk.com/2011/03/gaming-thats-good-for-your-health.html
(via recalculate-restate-reverberate)
[video]
I love my lab. Where else could I find engineering blend so well with neuroscience? The above photo was taken today at the UCSD Institute of Neural Computation’s Machine Perception Lab, where I work. I am going to talk about them more.
The photo is of a display that they have managed to construct in a matter of days from a hacked a flat screen TV and a small cluster of macbook minis. It looks like a whole project, but it’s only part of a demonstration. They are demonstrating our lab’s software that will take multiple video inputs and do everything from attentional scanning of a room to real time facial emotion detection. Their work is brilliant. I hope I can continue to learn from them.
(Source: inconcertwithmonsters)