generated from BloomTech-Labs/template-ds
-
Notifications
You must be signed in to change notification settings - Fork 4
/
application.py
83 lines (62 loc) · 1.96 KB
/
application.py
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import os
from flask import Flask, request, jsonify
from flask_cors import CORS
from helper import check_entry, generate_and_save
def create_app():
application = Flask(__name__)
CORS(application)
@application.route('/')
def root():
return "Index; nothing to see here."
@application.route('/entry', methods=['POST'])
def check_url():
reqs = request.get_json()['params']
preview = reqs['preview']
video_id = reqs['video_id']
# default values initiated
resolution = '128'
im_group = None
jitter = 0.5
depth = 1
truncation = 0.5
pitch_sensitivity = 220
tempo_sensitivity = 0.25
smooth_factor = 20
# checks to see if other values are specified by user
if 'resolution' in reqs:
resolution = reqs['resolution']
if 'im_group' in reqs:
im_group = reqs['im_group']
if 'jitter' in reqs:
jitter = reqs['jitter']
if 'depth' in reqs:
depth = reqs['depth']
if 'truncation' in reqs:
truncation = reqs['truncation']
if 'pitch_sensitivity' in reqs:
pitch_sensitivity = reqs['pitch_sensitivity']
if 'tempo_sensitivity' in reqs:
tempo_sensitivity = reqs['tempo_sensitivity']
if 'smooth_factor' in reqs:
smooth_factor = reqs['smooth_factor']
return check_entry(preview, video_id, resolution, im_group, jitter,
depth, truncation, pitch_sensitivity,
tempo_sensitivity, smooth_factor)
@application.route('/visualize', methods=['POST'])
def visual():
reqs = request.get_json()
preview = reqs['preview']
video_id = str(reqs['video_id'])
resolution = str(reqs['resolution'])
classes = reqs['classes']
jitter = reqs['jitter']
depth = reqs['depth']
truncation = reqs['truncation']
pitch_sensitivity = reqs['pitch_sensitivity']
tempo_sensitivity = reqs['tempo_sensitivity']
smooth_factor = reqs['smooth_factor']
return generate_and_save(preview, video_id, resolution, classes,
jitter, depth, truncation,
pitch_sensitivity, tempo_sensitivity,
smooth_factor)
return application