Skip to content

TheCulliganMan/practice-repo

Repository files navigation

practice-repo

Multiple web servers in python

To start

The following command will pull and build the docker files described in the docker-compose.yml

docker-compose build

Now we want to start the app.

docker-compose up -d  # d is for daemon

Now the app should be running with its' copies of mongodb and redis. (this can be shortened to docker-compose up --build -d)

It is probably about time to check the logs of the application. We can do this by typing:

docker-compose logs -f  # f is for follow

Without docker compose

You can acheive the same end without using docker-compose. I don't know why you would. The code below should be roughly what you would need to do, in this case you will need to change the linkage of the containers to localhost:port instead of redis:port and mongo:port.

cd PracticeApp
docker build -t practiceapp .
docker run -name mongo -d -p 27017:27017 mongo:latest
docker run -name redis -d -p 6379:6379 redis:latest
docker run -name practiceapp -p 93:8000 -d practiceapp

General Notes

Tools

PyTest

Jupyter / Jupyter Lab

  • if you haven't used these check them out this week. pip install jupyter
  • super cool repl for python
  • web based and allows exposed kernels to a web browser
  • inline visualization
  • markdown support!!!
  • R / Haskel / Scala Support
  • just super cool.

Requests

Rest Servers

Flask

  • great general purpose framework
  • the best to develop quickly in
  • tons of extensions
  • mid / fast

Flask-Restful

  • flask plugin for rest
  • slow, but has a good structure.
  • uses http verbs to define classes(PUT POST GET DELETE, ETC)

Falcon

  • You manage everything by hand
  • not as many extensions
  • fast. 20x the speed (reqs per second) of flask
  • runs great on pypy!

ApiStar

  • kinda strange syntax

  • fast, not as fast as falcon but fast.

  • self documenting!!!!

    • automatically creates a /docs/ endpoint that shows how to call the api in javascript and python

Redis

MongoDB

About

Python Web API Docker Compose

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published