Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update Victoria starun hw12 #84

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions less18/less18.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import requests
import js2py



# url = "https://uakino.club"

# print(r.status_code)
# print(r.status_code)
# print(r.content)
# print(r.text)

# def get_uakino():
# url = "https://uakino.club"
# my_headers = {"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36"}
# # Host: may als be needed

# req = requests.get(url, headers=my_headers)

# print(url)
# print(req.status_code)
# print(req.headers)

# get_uakino()

#post-installed headers, after login for example

def post_uakino():
url = "https://uakino.club"
my_headers = {"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36"}

my_data = {
"login_name": "testmad",
"login_password": "not-a-real-password-lol"
}

req = requests.post(url, headers=my_headers, json=my_data)

print(req.request.body)
print(req.url)
# print(req.headers)
print(req.status_code)
# print(req.text)

post_uakino()
53 changes: 53 additions & 0 deletions less18/less18hw.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import requests

base_url = "https://petstore.swagger.io/v2"

def get_all_pets_by_all_statuses():
r = requests.get(base_url+"/pet/findByStatus/",
params={"status":"available",
"status":"pending",
"status":"sold"})
if r.status_code == 200:
print("Success")
print(r._content)
else:
print ("Something went wrong. Status code:", r.status_code)


def create_new_pet():
new_pet_data = {"id":70999,
"name":"coolPet",
"status":"pending"}

r = requests.post(base_url+"/pet", json=new_pet_data)

if r.status_code == 200:
print("Success")
print(r._content)
else:
print ("Something went wrong. Status code:", r.status_code)

def get_pet_by_id(petId):

r = requests.get(base_url+"/pet/"+petId)

if r.status_code == 200 or r.status_code == 201: #may be expected 201, but for now server responds with 200
print("Success")
print(r._content)
else:
print ("Something went wrong. Status code:", r.status_code)

def delete_pet_by_id(petId):

r = requests.delete(base_url+"/pet/"+petId)

if r.status_code == 200:
print("Success")
print(r._content)
else:
print ("Something went wrong. Status code:", r.status_code)

get_all_pets_by_all_statuses()
create_new_pet()
get_pet_by_id("70999")
delete_pet_by_id("70999")