Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I want to get the Server header of HTTP with Python. I don't know how can I get it, I looked at the RFC of Hypertext Transfer Protocol and got into the Server section.
The Server response-header field contains information about the
software used by the origin server to handle the request. The field
can contain multiple product tokens (section 3.8) and comments
identifying the server and any significant subproducts. The product
tokens are listed in order of their significance for identifying the
application.
How can we get it ? I can guess that with os or platform, etc.
I am assuming you want to:
Send HTTP requests to a web server and retrieve the 'Server' header
from the HTTP response.
You want to use python.
'requests' is a very popular lib to make HTTP requests (https://requests.readthedocs.io/en/master/)
Here is a code sample very may guide you achieving what you need
import requests
response = requests.get("http://example.com")
print(response.headers['Server'])
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I tried to use the Microsoft Graph API from the Request module in Python, but I was still new and didn't want to use Postman either. But I had a problem using the Request module:
How to select the application platform type?
How to fill in the redirect URL?
How to get refresher token and access token ?And how to renew(refresh) them?
How to get Tenant ID?
This is all my questions. I hope someone can help me solve them.
(This question by the machine translation, if there is a small mistake, also hope you understand.)
Congrats on your first question!
This is not a full answer that you might have been looking for, but take a look at the Microsoft Graph API docs
After you register your app and get authentication tokens for a user or service, you can make requests to the Microsoft Graph API.
Did you register your app? If not here are the docs
In your question it looks like you're describing the flow for get access on behalf of the user, but what you need is get access without a user. In order to use the API through the requests module you need to follow this tutorial
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I read about REST API specifications. These are the principles:
everything is a resource
each resource is identifiable by a unique identifier
use the standard HTTP methods
Now suppose there is a table for contact details
id , owner, contact name,contact number, created At
I want to design an API to consume the data. I can design the api in the following ways.
For getting the contact by owner
Get /contact/owner/david
or
Get /getContactByOwner?ownerName="david"
For writing into the table
post /contact/owner
{contactDetail JSON in request param}
or
post /addToContact?owner="john"&...
Which design is RESTful? What is wrong with the other one?
The rule of thumb with RESTful naming conventions is to use nouns as your endpoints (since your verbs should be limited to get / post / put / delete / etc). So in your example, Get contact/owner/david and Post contact/owner would be preferable. However, if you're really using REST architecture, you should technically be using HATEOAS (Hypertext-as-the-engine-of-application-state) and including links in XML or HTML responses, so if you're using JSON it's probably more REST-like as opposed to full-blown REST. At the end of the day, it's all a matter of preference; just try to use whatever will fit the needs of the application's users in a way that's somewhat self-documenting and intuitive.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I am confused with the etag mechanism. If anyone could explain it, would be a big help
So first lets separate etags from django/python. The concept of etags, lives independently of any programming language. It is actually part of HTTP.
Simply put etags are part of the way one might go about implementing a web cache. Basically the server returns an ETag header which is a hash that represents the state of a resource. The client can then send that hash value to the server which can perform a check, if it matches then the cache the client has is still valid 304. If the values are different then the server would send a full response back to the client.
Basically outlined on Wiki :)
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
If I want to give input to the website through python program and display the result on terminal after online computation then how can I do it using python wrapper? As I am new to python, so Can anyone suggest me some tutorial for this?
It all depends on the website that you want to retrieve your result from, and how it accepts input from you. For example, if your webpage accepts GET or POST requests, then you can send it a HTTP request and print out the response onto terminal.
If your website accepts input via a submit form, on the other hand, you would have to find the link of the submit button and send your data to that page.
There is a Python library called Requests, which you can use to send HTTP requests to a webpage and get the response. I suggest you read its documentation, it has some good examples that you can base your idea off. Another library is the inbuilt urllib2, which would also work for your purposes.
The response to your request is most likely to be a HTTP webpage, so you may have to scrape out your desired content from inside that.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
Are there any equivalents in objective-c to the following python urllib2 functions?
Request, urlopen, HTTPError, HTTPCookieProRequest, urlopen, HTTPError, HTTPCookieProcessor
Also, how would I able to to this and change the method from "get" to "post"?
NSMutableHTTPURLRequest, a category of NSMutableURLRequest, is how you set up an HTTP request. Using that class you will specify a method (GET or POST), headers and a url.
NSURLConnection is how you open the connection. You will pass in a request and delegate, and the delegate will receive data, errors and messages related to the connection as they become available.
NSHTTPCookieStorage is how you manage existing cookies. There are a number of related classes in the NSHTTPCookie family.
With urlopen, you open a connection and read from it. There is no direct equivalent to that unless you use something lower level like CFReadStreamCreateForHTTPRequest. In Objective-C everything is passive, where you are notified when events occur on the stream.
You're looking for some combination of NSURL, NSURLRequest, NSURLConnection, NSHTTPConnection, etc. Check out the URL Loading System Programming Guide for all the information you need.