How are POST and GET variables handled in Python?

suppose you’re posting a html form with this: <input type=”text” name=”username”> If using raw cgi: import cgi form = cgi.FieldStorage() print form[“username”] If using Django, Pylons, Flask or Pyramid: print request.GET[‘username’] # for GET form method print request.POST[‘username’] # for POST form method Using Turbogears, Cherrypy: from cherrypy import request print request.params[‘username’] Web.py: form = … Read more

How to download HTTP directory with all files and sub-directories as they appear on the online files/folders list?

Solution: wget -r -np -nH –cut-dirs=3 -R index.html http://hostname/aaa/bbb/ccc/ddd/ Explanation: It will download all files and subfolders in ddd directory -r : recursively -np : not going to upper directories, like ccc/… -nH : not saving files to hostname folder –cut-dirs=3 : but saving it to ddd by omitting first 3 folders aaa, bbb, ccc … Read more

404 error for Google Tag Manager

You need to publish a version of your container. If it is not published, the request will return a 404 error. To publish your current workspace: Click Submit at the top right hand side of the screen. The Submit Changes screen will appear, with options to publish the container and save a version of your … Read more

Sending a JSON to server and retrieving a JSON in return, without JQuery

Sending and receiving data in JSON format using POST method // Sending and receiving data in JSON format using POST method // var xhr = new XMLHttpRequest(); var url = “url”; xhr.open(“POST”, url, true); xhr.setRequestHeader(“Content-Type”, “application/json”); xhr.onreadystatechange = function () { if (xhr.readyState === 4 && xhr.status === 200) { var json = JSON.parse(xhr.responseText); console.log(json.email … Read more

How do I do a HTTP GET in Java? [duplicate]

If you want to stream any webpage, you can use the method below. import java.io.*; import java.net.*; public class c { public static String getHTML(String urlToRead) throws Exception { StringBuilder result = new StringBuilder(); URL url = new URL(urlToRead); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod(“GET”); try (BufferedReader reader = new BufferedReader( new InputStreamReader(conn.getInputStream()))) { for … Read more

http HEAD vs GET performance

A RESTful URI should represent a “resource” at the server. Resources are often stored as a record in a database or a file on the filesystem. Unless the resource is large or is slow to retrieve at the server, you might not see a measurable gain by using HEAD instead of GET. It could be … Read more

get all keys set in memcached

Found a way, thanks to the link here (with the original google group discussion here) First, Telnet to your server: telnet 127.0.0.1 11211 Next, list the items to get the slab ids: stats items STAT items:3:number 1 STAT items:3:age 498 STAT items:22:number 1 STAT items:22:age 498 END The first number after ‘items’ is the slab … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)