Spaces:
Sleeping
Sleeping
File size: 1,525 Bytes
1bc8781 6410048 1bc8781 6410048 1bc8781 1a3de10 fd8681a 71d387b 1bc8781 94cebf0 fd8681a 71d387b 1bc8781 0bb6a33 658d835 2d354b5 658d835 f3edc8b 515a25e cb539fd e34db5a 5b172f5 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 |
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
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
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('/getresource', methods=['GET'])
def getresource():
res = request.args.get('r')
return app.send_static_file(res)
@ app.route('/novo-front/<file>')
def novofront(file):
newfile = 'novo-front/'+file+'.html'
print(newfile)
return app.send_static_file(newfile)
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)
|