Spaces:
Runtime error
Runtime error
Commit ·
4603dd2
1
Parent(s): a3a7599
Update server.py
Browse files
server.py
CHANGED
|
@@ -23,7 +23,7 @@ allow_headers=["*"], # Allows all headers
|
|
| 23 |
# API_TOKEN = os.environ["API_TOKEN"]
|
| 24 |
API_TOKEN = '34dsadfF$$%#$TGREGEFGE%Q*)(*&%'
|
| 25 |
|
| 26 |
-
card_is_running =
|
| 27 |
|
| 28 |
# ---------------------------------------------------------------------------
|
| 29 |
# - Token auth method -
|
|
@@ -49,13 +49,15 @@ def delete_old_files():
|
|
| 49 |
os.remove(os.path.join(path, filename))
|
| 50 |
|
| 51 |
@app.on_event("startup")
|
| 52 |
-
def startup_event(
|
| 53 |
'''
|
| 54 |
Create out dir
|
| 55 |
'''
|
| 56 |
if not os.path.exists("/tmp"):
|
| 57 |
os.makedirs("/tmp")
|
| 58 |
|
|
|
|
|
|
|
| 59 |
@app.get("/")
|
| 60 |
async def root():
|
| 61 |
response = RedirectResponse(url='/docs')
|
|
@@ -76,7 +78,7 @@ async def resolution(request : Request, background_tasks: BackgroundTasks, respo
|
|
| 76 |
|
| 77 |
image = io.BytesIO(await data.read())
|
| 78 |
image.seek(0)
|
| 79 |
-
|
| 80 |
background_tasks.add_task(check_gpu_usage)
|
| 81 |
result = cardtagger(image.read())
|
| 82 |
card_is_running = False
|
|
|
|
| 23 |
# API_TOKEN = os.environ["API_TOKEN"]
|
| 24 |
API_TOKEN = '34dsadfF$$%#$TGREGEFGE%Q*)(*&%'
|
| 25 |
|
| 26 |
+
card_is_running = True
|
| 27 |
|
| 28 |
# ---------------------------------------------------------------------------
|
| 29 |
# - Token auth method -
|
|
|
|
| 49 |
os.remove(os.path.join(path, filename))
|
| 50 |
|
| 51 |
@app.on_event("startup")
|
| 52 |
+
def startup_event(background_tasks: BackgroundTasks):
|
| 53 |
'''
|
| 54 |
Create out dir
|
| 55 |
'''
|
| 56 |
if not os.path.exists("/tmp"):
|
| 57 |
os.makedirs("/tmp")
|
| 58 |
|
| 59 |
+
background_tasks.add_task(check_gpu_usage)
|
| 60 |
+
|
| 61 |
@app.get("/")
|
| 62 |
async def root():
|
| 63 |
response = RedirectResponse(url='/docs')
|
|
|
|
| 78 |
|
| 79 |
image = io.BytesIO(await data.read())
|
| 80 |
image.seek(0)
|
| 81 |
+
|
| 82 |
background_tasks.add_task(check_gpu_usage)
|
| 83 |
result = cardtagger(image.read())
|
| 84 |
card_is_running = False
|