├── README.md
├── python-on-the-backend-lecture10
├── README.md
└── index.py
├── python-on-the-backend-lecture11
├── README.md
├── index.html
└── index.py
├── python-on-the-backend-lecture13
├── README.md
├── index.html
└── index.py
├── python-on-the-backend-lecture14
├── README.md
├── index.html
└── index.py
├── python-on-the-backend-lecture15
├── README.md
├── index.html
├── index.py
└── list.txt
├── python-on-the-backend-lecture16
├── README.md
├── index.html
├── index.py
└── list.txt
├── python-on-the-backend-lecture17-bonus
├── README.md
├── index.html
├── index.py
└── list.txt
└── python-on-the-backend-lecture18-bonus
├── README.md
├── index.html
├── index.py
└── upload
└── c#course (2).png
/README.md:
--------------------------------------------------------------------------------
1 | # python-on-the-backend
2 | Python on the Back-end for Beginners video course
3 |
--------------------------------------------------------------------------------
/python-on-the-backend-lecture10/README.md:
--------------------------------------------------------------------------------
1 | # python-on-the-backend
2 | Python on the Back-end for Beginners video course
3 |
--------------------------------------------------------------------------------
/python-on-the-backend-lecture10/index.py:
--------------------------------------------------------------------------------
1 | import tornado.web
2 | import tornado.ioloop
3 |
4 | class basicRequestHandler(tornado.web.RequestHandler):
5 | def get(self):
6 | self.write("Hello, World this is a python command executed from the backend.")
7 |
8 | if __name__ == "__main__":
9 | app = tornado.web.Application([
10 | (r"/", basicRequestHandler)
11 | ])
12 |
13 | port = 8882
14 | app.listen(port)
15 | print(f"Application is ready and listening on port {port}")
16 | tornado.ioloop.IOLoop.current().start()
--------------------------------------------------------------------------------
/python-on-the-backend-lecture11/README.md:
--------------------------------------------------------------------------------
1 | # python-on-the-backend
2 | Python on the Back-end for Beginners video course
3 |
--------------------------------------------------------------------------------
/python-on-the-backend-lecture11/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | List of Animals
8 |
9 |
10 | This is a list of Animals
11 |
17 |
18 |
--------------------------------------------------------------------------------
/python-on-the-backend-lecture11/index.py:
--------------------------------------------------------------------------------
1 | import tornado.web
2 | import tornado.ioloop
3 |
4 | class basicRequestHandler(tornado.web.RequestHandler):
5 | def get(self):
6 | self.write("Hello, World this is a python command executed from the backend.")
7 |
8 |
9 | class listRequestHandler(tornado.web.RequestHandler):
10 | def get(self):
11 | self.render("index.html")
12 |
13 | if __name__ == "__main__":
14 | app = tornado.web.Application([
15 | (r"/", basicRequestHandler),
16 | (r"/animal", listRequestHandler)
17 | ])
18 |
19 | port = 8882
20 | app.listen(port)
21 | print(f"Application is ready and listening on port {port}")
22 | tornado.ioloop.IOLoop.current().start()
--------------------------------------------------------------------------------
/python-on-the-backend-lecture13/README.md:
--------------------------------------------------------------------------------
1 | # python-on-the-backend
2 | Python on the Back-end for Beginners video course
3 |
--------------------------------------------------------------------------------
/python-on-the-backend-lecture13/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | List of Animals
8 |
9 |
10 | This is a list of Animals
11 |
17 |
18 |
--------------------------------------------------------------------------------
/python-on-the-backend-lecture13/index.py:
--------------------------------------------------------------------------------
1 | import tornado.web
2 | import tornado.ioloop
3 |
4 | class basicRequestHandler(tornado.web.RequestHandler):
5 | def get(self):
6 | self.write("Hello, World this is a python command executed from the backend.")
7 |
8 |
9 | class queryParamRequestHandler(tornado.web.RequestHandler):
10 | def get(self):
11 | num = self.get_argument("num")
12 | if (num.isdigit()):
13 | r = "odd" if int(num) % 2 else "even"
14 | self.write(f"The integer {num} is {r}")
15 | else:
16 | self.write(f"{num} is not a valid integer.")
17 |
18 | class listRequestHandler(tornado.web.RequestHandler):
19 | def get(self):
20 | self.render("index.html")
21 |
22 | if __name__ == "__main__":
23 | app = tornado.web.Application([
24 | (r"/", basicRequestHandler),
25 | (r"/animal", listRequestHandler),
26 | (r"/isEven", queryParamRequestHandler)
27 | ])
28 |
29 | port = 8882
30 | app.listen(port)
31 | print(f"Application is ready and listening on port {port}")
32 | tornado.ioloop.IOLoop.current().start()
--------------------------------------------------------------------------------
/python-on-the-backend-lecture14/README.md:
--------------------------------------------------------------------------------
1 | # python-on-the-backend
2 | Python on the Back-end for Beginners video course
3 |
--------------------------------------------------------------------------------
/python-on-the-backend-lecture14/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | List of Animals
8 |
9 |
10 | This is a list of Animals
11 |
17 |
18 |
--------------------------------------------------------------------------------
/python-on-the-backend-lecture14/index.py:
--------------------------------------------------------------------------------
1 | import tornado.web
2 | import tornado.ioloop
3 |
4 | class basicRequestHandler(tornado.web.RequestHandler):
5 | def get(self):
6 | self.write("Hello, World this is a python command executed from the backend.")
7 |
8 |
9 | class queryParamRequestHandler(tornado.web.RequestHandler):
10 | def get(self):
11 | num = self.get_argument("num")
12 | if (num.isdigit()):
13 | r = "odd" if int(num) % 2 else "even"
14 | self.write(f"The integer {num} is {r}")
15 | else:
16 | self.write(f"{num} is not a valid integer.")
17 |
18 | class listRequestHandler(tornado.web.RequestHandler):
19 | def get(self):
20 | self.render("index.html")
21 |
22 | class resourceParamRequestHandler(tornado.web.RequestHandler):
23 | def get(self,studentName, courseId):
24 | self.write(f"Welcome {studentName} you are viewing course {courseId}")
25 |
26 |
27 | if __name__ == "__main__":
28 | app = tornado.web.Application([
29 | (r"/", basicRequestHandler),
30 | (r"/animal", listRequestHandler),
31 | (r"/isEven", queryParamRequestHandler),
32 | (r"/students/([a-z]+)/([0-9]+)", resourceParamRequestHandler)
33 | ])
34 |
35 | port = 8882
36 | app.listen(port)
37 | print(f"Application is ready and listening on port {port}")
38 | tornado.ioloop.IOLoop.current().start()
--------------------------------------------------------------------------------
/python-on-the-backend-lecture15/README.md:
--------------------------------------------------------------------------------
1 | # python-on-the-backend
2 | Python on the Back-end for Beginners video course
3 |
--------------------------------------------------------------------------------
/python-on-the-backend-lecture15/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | List of Animals
8 |
9 |
10 |
11 | This is a list of Animals
12 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/python-on-the-backend-lecture15/index.py:
--------------------------------------------------------------------------------
1 | import tornado.web
2 | import tornado.ioloop
3 | import json
4 |
5 | class listRequestHandler(tornado.web.RequestHandler):
6 | def get(self):
7 | fh = open("list.txt", "r")
8 | fruits = fh.read().splitlines()
9 | fh.close()
10 | self.write(json.dumps(fruits))
11 |
12 | if __name__ == "__main__":
13 | app = tornado.web.Application([
14 | (r"/list", listRequestHandler)
15 | ])
16 |
17 | port = 8882
18 | app.listen(port)
19 | print(f"Application is ready and listening on port {port}")
20 | tornado.ioloop.IOLoop.current().start()
--------------------------------------------------------------------------------
/python-on-the-backend-lecture15/list.txt:
--------------------------------------------------------------------------------
1 | Banana
2 | Grapes
3 | Orange
4 | Lemons
5 | Avocado
--------------------------------------------------------------------------------
/python-on-the-backend-lecture16/README.md:
--------------------------------------------------------------------------------
1 | # python-on-the-backend
2 | Python on the Back-end for Beginners video course
3 |
--------------------------------------------------------------------------------
/python-on-the-backend-lecture16/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | List of Animals
8 |
9 |
10 |
11 | This is a list of Animals
12 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/python-on-the-backend-lecture16/index.py:
--------------------------------------------------------------------------------
1 | import tornado.web
2 | import tornado.ioloop
3 | import json
4 |
5 | class listRequestHandler(tornado.web.RequestHandler):
6 | def get(self):
7 | fh = open("list.txt", "r")
8 | fruits = fh.read().splitlines()
9 | fh.close()
10 | self.write(json.dumps(fruits))
11 | def post(self):
12 | fruit = self.get_argument("fruit")
13 | fh = open("list.txt", "a")
14 | fh.write(f"{fruit}\n")
15 | fh.close()
16 | self.write(json.dumps({"message": "Fruit added successfully."}))
17 |
18 | if __name__ == "__main__":
19 | app = tornado.web.Application([
20 | (r"/list", listRequestHandler)
21 | ])
22 |
23 | port = 8882
24 | app.listen(port)
25 | print(f"Application is ready and listening on port {port}")
26 | tornado.ioloop.IOLoop.current().start()
--------------------------------------------------------------------------------
/python-on-the-backend-lecture16/list.txt:
--------------------------------------------------------------------------------
1 | Banana
2 | Grapes
3 | Orange
4 | Lemons
5 | Avocado
6 | Cherry
7 |
--------------------------------------------------------------------------------
/python-on-the-backend-lecture17-bonus/README.md:
--------------------------------------------------------------------------------
1 | # python-on-the-backend
2 | Python on the Back-end for Beginners video course
3 |
--------------------------------------------------------------------------------
/python-on-the-backend-lecture17-bonus/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Fruits API
8 |
9 |
10 |
11 |
12 |
13 |
14 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/python-on-the-backend-lecture17-bonus/index.py:
--------------------------------------------------------------------------------
1 | import tornado.web
2 | import tornado.ioloop
3 | import json
4 | class mainRequestHandler(tornado.web.RequestHandler):
5 | def get(self):
6 | self.render("index.html")
7 | class listRequestHandler(tornado.web.RequestHandler):
8 | def get(self):
9 | fh = open("list.txt", "r")
10 | fruits = fh.read().splitlines()
11 | fh.close()
12 | self.write(json.dumps(fruits))
13 | def post(self):
14 | fruit = self.get_argument("fruit")
15 | fh = open("list.txt", "a")
16 | fh.write(f"{fruit}\n")
17 | fh.close()
18 | self.write(json.dumps({"message": "Fruit added successfully."}))
19 |
20 | if __name__ == "__main__":
21 | app = tornado.web.Application([
22 | (r"/", mainRequestHandler),
23 | (r"/list", listRequestHandler)
24 | ])
25 |
26 | port = 8882
27 | app.listen(port)
28 | print(f"Application is ready and listening on port {port}")
29 | tornado.ioloop.IOLoop.current().start()
--------------------------------------------------------------------------------
/python-on-the-backend-lecture17-bonus/list.txt:
--------------------------------------------------------------------------------
1 | Banana
2 | Grapes
3 | Orange
4 | Lemons
5 | Avocado
6 | CherryApple
7 | Peach
8 | Peach
9 |
--------------------------------------------------------------------------------
/python-on-the-backend-lecture18-bonus/README.md:
--------------------------------------------------------------------------------
1 | # python-on-the-backend
2 | Python on the Back-end for Beginners video course
3 |
--------------------------------------------------------------------------------
/python-on-the-backend-lecture18-bonus/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Document
8 |
9 |
10 |
14 |
15 |
--------------------------------------------------------------------------------
/python-on-the-backend-lecture18-bonus/index.py:
--------------------------------------------------------------------------------
1 | import tornado.web
2 | import tornado.ioloop
3 |
4 | class uploadImgHandler(tornado.web.RequestHandler):
5 | def post(self):
6 | files = self.request.files["fileImage"]
7 | for f in files:
8 | fh = open(f"upload/{f.filename}", "wb")
9 | fh.write(f.body)
10 | fh.close()
11 | self.write(f"http://localhost:8080/img/{f.filename}")
12 | def get(self):
13 | self.render("index.html")
14 |
15 | if (__name__ == "__main__"):
16 | app = tornado.web.Application([
17 | ("/", uploadImgHandler),
18 | ("/img/(.*)", tornado.web.StaticFileHandler, {'path': 'upload'})
19 | ])
20 |
21 | app.listen(8080)
22 | print("Listening on port 8080")
23 | tornado.ioloop.IOLoop.instance().start()
--------------------------------------------------------------------------------
/python-on-the-backend-lecture18-bonus/upload/c#course (2).png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hnasr/python-on-the-backend/9c124131c0416db83a5147564c86e0c9b7e7cace/python-on-the-backend-lecture18-bonus/upload/c#course (2).png
--------------------------------------------------------------------------------