This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from flask import Flask | |
| from bs4 import BeautifulSoup | |
| import requests | |
| import os | |
| import json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| app = Flask(__name__) # Create an instance of Flask | |
| # the / route | |
| @app.route("/") | |
| def home(): | |
| return json.dumps({"docker":"flask"}) | |
| # Run the app | |
| if __name__ == "__main__": | |
| app.run(debug=True, port=5000) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| keys = [ | |
| "Country", | |
| "Total Cases", | |
| "New Cases", | |
| "Total Deaths", | |
| "New Deaths", | |
| "Total Recovered", | |
| "New Recovered", | |
| "Active Cases", | |
| ] # the keys of the table |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| s, e = 0, len(keys) | |
| entries = [] | |
| # Loop through the temp list and make a dict with every 9 items | |
| for _ in range(len(tmp) // len(keys)): | |
| d = dict(zip(keys, tmp[s:e])) | |
| if d: | |
| entries.append(d) | |
| s += len(keys) | |
| e += len(keys) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @app.route("/show/<country>") | |
| def get_country(country): | |
| entries = get_info_table() | |
| if country == "all": | |
| return json.dumps(entries) | |
| else: | |
| for entry in entries["data"]: | |
| if entry["Country"] == country.lower(): | |
| return json.dumps(entry) | |
| return json.dumps({"error": f"Country not found: {country}"}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # syntax=docker/dockerfile:1 | |
| FROM python:3.8-slim-buster | |
| WORKDIR /code | |
| COPY . . | |
| EXPOSE 5000 | |
| RUN pip3 install -r requirements.txt | |
| CMD [ "python3", "-m" , "flask", "run", "--host=0.0.0.0"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # docker-compose.yml | |
| version: "3.2" | |
| services: | |
| web: | |
| build: . # where the Dockerfile is located | |
| ports: | |
| - 5000:5000 # container:host | |
| environment: | |
| - URL=https://www.worldometers.info/coronavirus/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import re | |
| import dateutil.parser as dparser | |
| conversions = {} | |
| # Define the folder containing the files to be renamed | |
| PATH = os.path.join(os.getcwd(),"files") | |
| def create_dummy_files(): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # For webcam input: | |
| cap = cv2.VideoCapture(0) | |
| with mp_face_detection.FaceDetection() as face_detection: | |
| while cap.isOpened(): | |
| success, image = cap.read() | |
| while not success: | |
| success, image = cap.read() | |
| # To improve performance, optionally mark the image as not writeable to | |
| # pass by reference. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cap = cv2.VideoCapture(0) | |
| with mp_face_detection.FaceDetection() as face_detection: | |
| while cap.isOpened(): | |
| success, image = cap.read() | |
| while not success: | |
| success, image = cap.read() |
OlderNewer