forked from codingforentrepreneurs/OpenCV-REST-API
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
25 lines (19 loc) · 820 Bytes
/
__init__.py
File metadata and controls
25 lines (19 loc) · 820 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import os
from flask import Flask, send_from_directory, request
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
UPLOAD_DIR = os.path.join(BASE_DIR, "storage", "upload")
RESULTS_DIR = os.path.join(BASE_DIR, "storage", "results")
OUTPUT_DIR = os.path.join(BASE_DIR, "storage", "output")
ALLOWED_EXTENSIONS = ['png', 'jpg', 'jpeg', 'gif']
for d in [UPLOAD_DIR, RESULTS_DIR, OUTPUT_DIR]:
os.makedirs(d, exist_ok=True)
app = Flask(__name__)
app.config['UPLOAD_FOLDER'] = UPLOAD_DIR
app.config['OUTPUT_DIR'] = OUTPUT_DIR
PORT = os.environ.get('PORT') or 5000
app.config['SERVER_NAME'] = os.environ.get('SERVER_NAME') or f'127.0.0.1:{PORT}'
def allowed_file(filename):
return "." in filename and \
filename.rsplit(".", 1)[1].lower() in ALLOWED_EXTENSIONS
from .views import *
from .cv.views import *