Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4a21260

Browse files
first exercise
0 parents commit 4a21260

File tree

5 files changed

+113
-0
lines changed

5 files changed

+113
-0
lines changed

‎.gitignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Ignore everything
2+
/*
3+
4+
!.gitignore
5+
!.gitpod.yml
6+
!.gitpod.Dockerfile
7+
!bc.json
8+
!README.md
9+
10+
!/exercises
11+
!/exercises/*
12+
13+
*.pyc
14+
__pycache__/
15+
.pytest_cache/
16+
17+
!/.breathecode
18+
/.breathecode/**
19+
!/.breathecode/resets
20+
!/.breathecode/resets/**

‎bc.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"port": 3000,
3+
"address": "localhost",
4+
"editor": "standalone",
5+
"outputPath": "./.breathecode/dist",
6+
"publicPath": "/preview",
7+
"grading": "isolated",
8+
"ignoreRegex": null,
9+
"webpack_template": null,
10+
"disable_grading": false,
11+
"onCompilerSuccess": null,
12+
"language": "python3",
13+
"compiler": "python3",
14+
"tester": "pytest",
15+
"actions": [
16+
"run",
17+
"test",
18+
"reset"
19+
],
20+
"session": 8780419452529280000,
21+
"exercisesPath": "./exercises",
22+
"exercises": [
23+
{
24+
"slug": "01-hello-world",
25+
"title": "01-hello-world",
26+
"path": "exercises/01-hello-world",
27+
"translations": [
28+
"us"
29+
]
30+
},
31+
{
32+
"slug": "01-what-is-a-request",
33+
"title": "01-what-is-a-request",
34+
"path": "exercises/01-what-is-a-request",
35+
"translations": [
36+
"us"
37+
]
38+
}
39+
]
40+
}

‎exercises/01-hello-world/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Hello World
2+
3+
Type here your exercise instructions
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# 02 What is a request
2+
3+
HTTP is a set of rules that allow two endpoints A - B to communicate with each other in only one direction:
4+
```txt
5+
A = Client B = Server
6+
```
7+
8+
- The client always asks a `request` to one server URL.
9+
- The server wais for request and answers max one `response` for each request.
10+
11+
In python this is how we make a request:
12+
13+
```python
14+
from http.client import HTTPSConnection
15+
16+
host_url = "assets.breatheco.de"
17+
path = "/apis/fake/hello.php"
18+
19+
conn = HTTPSConnection(host_url)
20+
conn.request("GET", path, body=None, headers={})
21+
22+
r1 = conn.getresponse()
23+
response = {
24+
"status": r1.status,
25+
"body": r1.read()
26+
}
27+
28+
print(response)
29+
```
30+
31+
# 📝 Instructions
32+
33+
Change the following code to print on the console `success` if the response status is between 200 and 399 or `fail` if the response is between 400 and 599.
34+
35+
Note: Only print success or fail, do not print anything else.

‎exercises/01-what-is-a-request/app.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from http.client import HTTPSConnection
2+
3+
host_url = "assets.breatheco.de"
4+
path = "/apis/fake/hello.php"
5+
6+
conn = HTTPSConnection(host_url)
7+
conn.request("GET", path, body=None, headers={})
8+
9+
r1 = conn.getresponse()
10+
response = {
11+
"status": r1.status,
12+
"body": r1.read()
13+
}
14+
15+
print(response)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /