-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
102 lines (88 loc) · 3.29 KB
/
server.py
File metadata and controls
102 lines (88 loc) · 3.29 KB
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from fastapi import FastAPI, UploadFile, File, Body
from fastapi.responses import JSONResponse
from typing import Dict, Any, List
import deepstrip_api
app = FastAPI(
title="DeepStrip API",
description="FastAPI wrapper for DeepStrip archive extractor and OrCAD indexer",
version="4.4.30"
)
@app.get("/healthz")
@app.get("/ping")
def health():
return {"status": "ok", "message": "DeepStrip API is live"}
@app.get("/info")
async def info():
return deepstrip_api.get_info()
@app.post("/process")
async def process_file(file: UploadFile = File(...)):
try:
contents = await file.read()
result = deepstrip_api.handle_process(contents, file.filename)
return JSONResponse(content=result)
except Exception as e:
return JSONResponse(content={"error": str(e)}, status_code=500)
@app.post("/extract")
async def extract(payload: Dict[str, Any] = Body(...)):
try:
result = deepstrip_api.handle_extract(payload)
return JSONResponse(content=result)
except Exception as e:
return JSONResponse(content={"error": str(e)}, status_code=500)
@app.post("/stream")
async def stream(payload: Dict[str, Any] = Body(...)):
try:
result = deepstrip_api.handle_stream(payload)
return JSONResponse(content=result)
except Exception as e:
return JSONResponse(content={"error": str(e)}, status_code=500)
@app.post("/analyze")
async def analyze(payload: Dict[str, Any] = Body(...)):
try:
result = deepstrip_api.handle_analyze(payload)
return JSONResponse(content=result)
except Exception as e:
return JSONResponse(content={"error": str(e)}, status_code=500)
@app.post("/scan-unlinked")
async def scan_unlinked(payload: Dict[str, Any] = Body(...)):
try:
result = deepstrip_api.handle_scan_unlinked(payload)
return JSONResponse(content=result)
except Exception as e:
return JSONResponse(content={"error": str(e)}, status_code=500)
@app.post("/hexdump")
async def hexdump(payload: Dict[str, Any] = Body(...)):
try:
result = deepstrip_api.handle_hexdump(payload)
return JSONResponse(content=result)
except Exception as e:
return JSONResponse(content={"error": str(e)}, status_code=500)
@app.post("/save")
async def save(payload: Dict[str, Any] = Body(...)):
try:
result = deepstrip_api.handle_save(payload)
return JSONResponse(content=result)
except Exception as e:
return JSONResponse(content={"error": str(e)}, status_code=500)
@app.post("/load")
async def load(payload: Dict[str, Any] = Body(...)):
try:
result = deepstrip_api.handle_load(payload)
return JSONResponse(content=result)
except Exception as e:
return JSONResponse(content={"error": str(e)}, status_code=500)
@app.post("/orcad/index")
async def orcad_index(files: List[UploadFile]):
try:
results = []
for f in files:
blob = await f.read()
results.append(deepstrip_api.handle_orcad_index(blob, f.filename))
return JSONResponse(content={"classified": results})
except Exception as e:
return JSONResponse(content={"error": str(e)}, status_code=500)
@app.post("/deploy")
async def trigger_deploy():
return deepstrip_api.handle_deploy()