how to create sessions in py?

Viewed 21

I have a python application and at first (first of all) it needs a record if you don't have an account and it's saved in a mysql database, but I have a question: how can I create these sessions? For example, I want each user to have their own data as a name.

here is an image as a base: image

1 Answers
# import requests module
import requests
 
# create a session object
s = requests.Session()
 
# set username and password
s.auth = ('user', 'pass')
 
# update headers
s.headers.update({'x-test': 'true'})
 
# both 'x-test' and 'x-test2' are sent
s.get('https://httpbin.org / headers', headers ={'x-test2': 'true'})
 
# print object
print(s)
Related