I am trying to send a GET request through postman using file URI scheme. An example:
file:///absolute/path/to/file.txt
The request works properly in any browser, but postman is failing with message:
Could not get any response
This seems to be like an error connecting to file:///absolute/path/to/file.txt
Is there any way to make postman work with file URIs?
Postman does not support file URIs, because the Chrome App platform does not allow direct access to files.
It should be easy to start a small HTTP server yourself though.. if you are on Mac/Linux, you can serve files in a directory using Python:
$ cd /path/to/directory/
$ python -m SimpleHTTPServer 1234
You can then visit
http://localhost:1234/filename
which will serve up the file.
Good answer.
I am not acquainted with SimpleHTTPServer, so I used live-server instead.
I followed the instructions at 2. Install and Run a Local Web Server to install live-server.
Then:
cd /path/to/(myJSONfile.json)
live-server <myJSONfile.json>
and the JSON file was opened in my default web browser.
Finally, in Postman I made a normal GET request, but on the address
http://127.0.0.1:8080.
It all worked just as intended.
In addition to czardoz's answer, for Python 3, SimpleHttpServer has been replaced by http.server. So, to serve the files using Python 3.x:
$ cd/path-to-directory/
$ python -m http.server 1234
Then, browse the file using:
http://localhost:1234/filename
Related
I am looking for the easiest way to download the kaggle competition data (train and test) on the virtual machine using bash to be able to train it there without uploading it on git.
Fast-forward three years later and you can use Kaggle's API using the CLI, for example:
kaggle competitions download favorita-grocery-sales-forecasting
First you need to copy your cookie information for kaggle site in a text file. There is a chrome extension which will help you to do this.
Copy the cookie information and save it as cookies.txt.
Now transfer the file to the EC2 instance using the command
scp -i /path/my-key-pair.pem /path/cookies.txt user-name#ec2-xxx-xx-xxx-x.compute-1.amazonaws.com:~
Accept the competitions rules and copy the URLs of the datasets you want to download from kaggle.com. For example the URL to download the sample_submission.csv file of Intel & MobileODT Cervical Cancer Screening competition is: https://kaggle.com/c/intel-mobileodt-cervical-cancer-screening/download/sample_submission.csv.zip
Now, from the terminal use the following command to download the dataset into the instance.
wget -x --load-cookies cookies.txt https://kaggle.com/c/intel-mobileodt-cervical-cancer-screening/download/sample_submission.csv.zip
Install CurlWget chrome extension.
start downloading your kaggle data-set. CurlWget will give you full wget command. paste this command to terminal with sudo.
Job is done.
Install cookies.txt extension on chrome and enable it.
Login to kaggle
Go to the challenge page that you want the data from
Click on cookie.txt extension on top right and it download the current page's cookie. It will download the cookies in cookies.txt file
Transfer the file to the remote service using scp or other methods
Copy the data link shown on kaggle page (right click and copy link address)
run wget -x --load-cookies cookies.txt <datalink>
When setting in the sample app: Travelocity.properties
#Specify if SAM LAssertion element is encrypted
SAML.EnableAssertionEncryption=true
And also tick the Identity server configuration option:
Enable Assertion Encryption [ticked]
Certificate Alias: wso2carbon
I receive the following error at the server log:
Error at Log: 2015-05-05 15:56:10,282 Error encrypting XMLObject
Without the encryption feature enabled, the SAML authentication flow with the Travelocity sample code starts working.
Hints are welcome how to fix this issue.
Regards,
Claude
It seems like you are working on the installed java runtime for the first time. I am using ubuntu 14. The same problem came to me. For me it worked in the following way.
1. Download the respective files according to your runtime from here.
http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html
http://www.oracle.com/technetwork/java/javase/downloads/jce-6-download-429243.html
http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html
2. Extract the folder you downloaded. There will be two .jar files.
3. For ubuntu you can run echo $JAVA_HOME to find the java home. Copy above jar files into {JAVA_HOME}/jre/lib/security. You may need sudo access depending on you JAVA_HOME location. If so run the following from the location you extracted the zip file.
cp local_policy.jar /{JAVA_HOME}/jre/lib/security
cp US_export_policy.jar /{JAVA_HOME}/jre/lib/security
There should be only one slash (/) at /{JAVA_HOME}.
4. Restart wso2 identity server again and retry the procedure to login to travelocity.com
Hope this will fix your issue.
"It works on my machine."
I have a django app. I'm followed this tutorial. OAuth2 works great on my dev box like this:
$ curl -v -H "Authorization: OAuth c52676b24a63b79a564b4ed38db3ac5439e51d47" http://localhost:8000/api/v1/my-model/?format=json
My local dev app finds the header with this line of code:
auth_header_value = request.META.get('HTTP_AUTHORIZATION')
But when I deploy it to my ubuntu box running apache it doesn't.
I added the following to my authentication.py file so I could inspect the values in the log on the remote machine.
logging.error(request.GET)
logging.error(request.POST)
logging.error(request.META)
The header value is mysteriously missing from the output. So I just get 401s.
Did you turn on WSGIPassAuthorization?
http://modwsgi.readthedocs.org/en/latest/configuration-directives/WSGIPassAuthorization.html
Authorisation headers are not passed through by default as doing so
could leak information about passwords through to a WSGI application
which should not be able to see them when Apache is performing
authorisation.
I've installed Flask-Restless and am trying to run the quickstart app. All requests return a 404 error (both in the python logs and in the curl response). My whole setup is:
$ virtualenv venv --distribute
$ source venv/bin/activate
$ pip install flask-restless
$ pip install flask-sqlalchemy # it doesn't appear to do this automatically
... Copy code from quickstart to "run.py" ...
$ python ./run.py
(another window)
$ curl -i http://127.0.0.1:5000/
The console output from run.py is:
* Running on http://127.0.0.1:5000/
* Restarting with reloader
127.0.0.1 - - [16/Apr/2013 17:08:05] "GET / HTTP/1.1" 404 -
The test.db does get created, and using the debugger I can see that app.run() does execute.
Interestingly, I get exactly the same behavior with Eve. I am able to run simple Flask apps, however.
In case it matters, this is OS X 10.8 and Python 2.7.3.
From the Flask-Restless documentation...
By default, the API for Person, in the above code samples, will be
accessible at http://<host>:<port>/api/person, where the person part
of the URL is the value of Person.__tablename__:
My guess is that by default, these frameworks do not set up an endpoint on the path /. They only have endpoints defined for paths related to actual objects in your API. Try the following...
curl -i http://127.0.0.1:5000/api/person
curl -i http://127.0.0.1:5000/person
These URLs might actually hit your endpoints that you're defining.
I have a html file with one button. When the button is clicked, a javascript function "run" is called:
function run() {
window.open("http://localhost/cgi-bin/run.py", "_self");
}
run.py is simply trying to run a helloworld.exe program, that outputs in a terminal the string "helloworld", but nothing happens, and browser keeps "waiting for localhost" indefinitely.
#!python
import sys, string, os, cgitb
cgitb.enable()
os.system("helloworld.exe")
I have tried helloworld.exe alone and it works, I have run run.py on the terminal, and it worked, and also I have tested on the browser the test site http://localhost/cgi-bin/helloworld.py, and it worked fine (helloworld.py is another script just to see if my apache is configured OK).
I am using wamp.
What I am trying to do is a bigger program that allows a client connect to a server, and "interact" with a program on the server side. The program is already done in c++, and won't be translated into php or javascript.
EDIT: I have been trying with the functions: subprocess.Popen, subprocess.call and os.system. I have also tested the code to run .exe files created by me living at apache/cgi-bin folder or executables like wordpad, living at c:\windows. And it always succeeds when the python script runs from the terminal, and it never works when trying from the browser. Is it possible that it is because of the server I am using? I use the apache from wamp, and have added the sentence "AddHandler cgi-script .exe" to the httpd.conf file.
I am sure it doesn't work locally. os.system returns you the exit code of the command, not its output.
You will need to use subprocess.Popen and pipeline the output to read the output.
import subprocess
p = subprocess.Popen("whatever.exe",stdout=subprocess.PIPE)
print p.stdout.read()
p.wait()
Also, the output of your CGI script is not valid HTTP protocol, and depending on your server that could be causing problems (some servers sanitize the output of the scripts, some others expect them to be written properly).
To me this code example works (on GNU/Linux using weborf as server, but it should be the same). You can try setting the content type and sending the \r\n\r\n final sequence. Servers are not expected to send that because the CGI script might want to add some more HTTP headers.
#!/usr/bin/env python
import cgitb
import subprocess
import sys
cgitb.enable()
sys.stdout.write("Content-type: text/plain\r\n\r\n")
p = subprocess.Popen("/usr/games/fortune",stdout=subprocess.PIPE)
data = p.stdout.read()
p.wait()
print data
In general my experience has been that if something works locally and doesn't work when you install all the same code on a different server, you are looking at a permissions problem. Check the permissions that visitors on your site have and make sure that the user coming through your web server has the right permissions to run helloworld.exe and run.py.