0

running the test script in python virtual environment

I am new to ubuntu and can you let me know how to how to run the test script in python virtual environment on Ubuntu 18.04

Python Ubuntu Add a comment
caden
asked Dec 11 2018

Answer

0

First, you ned to add the following lines in a file

#vim testing.py
import requests
r = requests.get('http://httpbin.org/get')
print(r.headers)

To run the script use the following command:

#python testing.py

output:

{'Connection': 'keep-alive', 'Server': 'gunicorn/19.9.0', 'Date': 'Sat, 01 Dec 2018 06:39:22 GMT', 'Content-Type': 'application/json', 'Content-Length': '266', 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Credentials': 'true', 'Via': '1.1 vegur'}
Add a comment
linuxhelp
asked Dec 14 2018
edited Dec 14 2018
Post your Answer