File size: 4,230 Bytes
1bc8781
 
 
 
 
 
 
8893f39
eed2326
1bc8781
 
 
 
54f62d8
1bc8781
 
87102b9
1bc8781
 
 
 
 
 
 
 
 
 
 
 
6410048
1bc8781
 
6410048
1bc8781
1a3de10
fd8681a
71d387b
1bc8781
94cebf0
fd8681a
71d387b
1bc8781
14a8b61
edb0b01
14a8b61
 
0bb6a33
658d835
a7768dc
a3ec249
a263a4a
a3ec249
 
 
 
 
 
 
 
 
 
658d835
0bb3bb0
 
 
f2172f4
0bb3bb0
 
 
 
 
 
 
cfdffcb
 
2e457b9
d0794d4
 
 
3b905ea
d0794d4
1471cb0
cfdffcb
51c254a
 
 
4b32352
54f62d8
47e61e5
a1228da
54f62d8
51c254a
 
0bb3bb0
e964357
 
 
f5a2840
 
e964357
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e3ef2e0
 
 
fe188af
dac5e30
93f6c0a
e3ef2e0
 
 
 
 
387c7d0
 
229eb2b
 
2fc19fb
 
1d2c511
 
 
abc68d0
1d2c511
8a490b5
656f5fb
cfdffcb
1bc8781
 
 
4d9867d
78d3b7b
 
 
 
 
 
 
1bc8781
 
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
import os
from datasets import load_dataset
import json
import uuid
from pathlib import Path
import json
from datasets import load_dataset
from flask import Flask, request, jsonify, Response
import requests
from flask_cors import CORS
from flask_apscheduler import APScheduler
import shutil
from PIL import Image
#import sqlite3
from huggingface_hub import Repository
import subprocess
import urllib.parse

app = Flask(__name__, static_url_path='/static')

CORS(app)



Path("static/images").mkdir(parents=True, exist_ok=True)



def update_repository():
   

    print("Updating repository")
   

@ app.route('/operacao')
def index():
    return app.send_static_file('operacao.html')

@ app.route('/operacaoTemplate.html')
def operacao():
    return app.send_static_file('operacaoTemplate.html')

@ app.route('/testeface')
def testeface():
    return app.send_static_file('testeface.html')

@ app.route('/getresource', methods=['GET'])
def getresource():
    argr = request.args.get('r')
    #return app.send_static_file(res)
    newurl = 'http://painel.atualli.com/getresource?r='+argr
   
    res = requests.get(newurl)

    headers = [
        (k,v) for k,v in res.raw.headers.items()
    ]
    
    response = Response(res.content, res.status_code, headers)
   
    return response

@ app.route('/novo-front/<file>')
def novofront(file):
    return app.send_static_file('novo-front/'+file+'.html')

@ app.route('/novo-front/css/<file>')
def novofrontcss(file):
    return app.send_static_file('novo-front/css/'+file)
    
@ app.route('/novo-front/img/<file>')
def novofrontimg(file):
    return app.send_static_file('novo-front/img/'+file)

@ app.route('/autentica', methods=['GET'])
def autentica():
    email = request.args.get('email')
    passw = request.args.get('passw')
    newurl = 'http://painel.atualli.com/autentica?email='+email+'&passw='+passw
    res = requests.get(newurl)

    response = Response(res.content, res.status_code, res.headers)
    return response

@ app.route('/proxyimg', methods=['GET'])
def proxyimg():
    newurl = request.args.get('img')
    #newurl = "http://painel.atualli.com:8098/getcamera?c=12"
    print(newurl)
    res = requests.get(newurl)
    print(res)
    response = Response(res.content, res.status_code, res.headers)
    return response
    
@ app.route('/getdatamosaico', methods=['GET'])
def getdatamosaico():
    cliente = request.args.get('cliente')
    operador = request.args.get('operador')
    newurl = 'http://painel.atualli.com/getdatamosaico?cliente='+cliente+"&operador="+operador
    res = requests.get(newurl)

    response = Response(res.content, res.status_code, res.headers)
    return response

@ app.route('/getdatalocal', methods=['GET'])
def getdatalocal():
    comando = request.args.get('comando')
    login = request.args.get('login')
    newurl = 'http://painel.atualli.com/getdatalocal?comando='+comando+"&login="+login
    res = requests.get(newurl)

    response = Response(res.content, res.status_code, res.headers)
    return response

@ app.route('/getpathvideo', methods=['GET'])
def getpathvideo():
    video = request.args.get('c')
   # new = urllib.parse.quote(video)
    newurl = 'http://painel.atualli.com/getpathrecord?c='+video
    print(newurl)
    res = requests.get(newurl)

    response = Response(res.content, res.status_code, res.headers,mimetype="video/mp4")
    return response
    
@ app.route('/<file>' , methods=['GET'])
def fileget(file):
    newurl = 'http://painel.atualli.com/'+file
    #newurl = 'http://atualli.ddns.net:8088/'+file
    res = requests.get(newurl)

    headers = [
        (k,v) for k,v in res.raw.headers.items()
    ]
    print(headers)
    response = Response(res.content, res.status_code, headers)
   
    return response

if __name__ == '__main__':
    mode = os.environ.get('FLASK_ENV', 'production')
    print(mode)
    dev = mode == 'development'
   
    print("Starting scheduler -- Running Production")
    scheduler = APScheduler()
    scheduler.add_job(id='Update Dataset Repository',
                      func=update_repository, trigger='interval', hours=1)
    scheduler.start()
   
    app.run(host='0.0.0.0',  port=int(
        os.environ.get('PORT', 7860)), debug=True, use_reloader=dev)