![]() Reference the previous tutorial for more information. Within the “app” directory the index.csv file as well as the files within the “pyimagesearch” directory are specific to, well, the image search engine. Don’t worry too much about how these work, but if you are curious you can reference the inline comments in the Dockerfile. The Dockerfile and the files with the “config” directory are used specifically to get our app up an running in the Docker container (if you used Docker, of course). Right now your project directory should look like this: ├── Dockerfile Essentially, we’re just going to wrap the image search engine in Flask. Since you’ve already built the search engine, we just need to transfer the relevant code to Flask. Create and activate a virtualenv, then install the requirements via Pip: $ pip install flask numpy scipy matplotlib scikit-image gunicorn Grab the _setup.zip from the repository, unzip the files, and add them to your project directory. Open your web browser and navigate to the IP address associated with the DOCKER_HOST variable – which should be if not, run boot2docker ip to get the correct address – you should see the text “Welcome!” in your browser. Once built, run the Docker container: $ docker run -p 80:5000 opencv-docker Now build the Docker image: $ docker build -rm -t opencv-docker. Then with boot2docker up and running, run docker version to test the Docker installation.Ĭreate a directory to house your project “flask-image-search”. If you don’t have Docker installed, follow the official Docker documentation to install both Docker and boot2docker. You can setup you development either with or without Docker. New to Flask? Start with the official Quickstart guide or the “Flask: QuickStart” chapter in the second Real Python course. More specifically, we’ll be creating a Single Page Application (SPA) that consumes data via AJAX (on the front-end) from an internal, REST-like API via Python/Flask (on the back-end). In this tutorial, we’ll take the command line image search engine from the previous tutorial and turn it into a full-blown web application using Python and Flask. This is a guest post by Michael Herman from Real Python – learn Python programming and web development through hands-on, interesting examples that are useful and fun! Click here to download the source code to this post
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |