https://github.com/starlord-daniel/flask-rest
A RESTful service based on the Flask Python framework
https://github.com/starlord-daniel/flask-rest
azure azure-cli azure-cognitive-services containers docker flask python
Last synced: 7 months ago
JSON representation
A RESTful service based on the Flask Python framework
- Host: GitHub
- URL: https://github.com/starlord-daniel/flask-rest
- Owner: starlord-daniel
- License: mit
- Created: 2017-12-02T14:06:40.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-06-26T06:59:36.000Z (over 7 years ago)
- Last Synced: 2025-03-20T17:38:31.979Z (7 months ago)
- Topics: azure, azure-cli, azure-cognitive-services, containers, docker, flask, python
- Language: Python
- Homepage:
- Size: 75.2 KB
- Stars: 4
- Watchers: 0
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# flask-rest
A RESTful service based on the Flask Python framework## Docker Container
This setup requires Docker to run on your PC. I've used Windows and Powershell to run the commands. You can find the downloads for [Windows](https://www.docker.com/docker-windows) and [Mac](https://www.docker.com/docker-mac) at the respective links.
The Create an image from the Flask service and run it and upload it as a web service, follow these steps:
### Build the image by running:
```docker
docker build -t .
```Where -t is used to set the tag for the image to create. The dot (.) at the end refers to the file path of the Dockerfile. For the build to work, the whole path can't contain any spaces. Something like C:\test would be fine, but "C:\test\this app" wouldn't be.
An example:
```docker
docker build -t flask-rest .
```### Run the container locally:
```docker
docker run -p 8000:8000
```The property -p sets the port mapping for the container. As the script exposes port 8000, this should be mapped to another port of the container. You might change the second value (right) to change the port to speak to.
An example:
```docker
docker run -p 8000:8000 flask-rest
```### **[Option 1/2]** Upload image to Docker Hub:
1. Login to docker from command line
```docker
docker login --username --password
```It is more secure, to use --password-stdin to login to your docker account:
```docker
$ cat ~/my_password.txt | docker login --username foo --password-stdin
```More information can be found in the [Docker Docs](https://docs.docker.com/engine/reference/commandline/login/#parent-command)
2. Push the image to Docker Hub:
```docker
docker push /:v1.0.0 .
```### **[Option 2/2]** Upload image to Azure Container Registry
0. Prepare for upload:
```shell
pip install --user azure-cli
```
If this doesn't work, download the installer and follow the instructions up on [Azure Docs](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest)1. Login to your container registry:
```docker
docker login .azurecr.io
```2. Push to your registry:
```docker
docker tag .azurecr.io/
docker push awesome.azurecr.io/
```More info in the [Azure Docs](https://docs.microsoft.com/en-us/azure/container-registry/container-registry-get-started-docker-cli)
## Create a web service from your Docker image
This chapter is in development.