{
"task_id": "654e9bf7-816e-4ea2-be2a-a04adcdf13af",
"message": "File processing started. Visit /result/{task_id} for results."
}
<!doctype html>
<html lang="en">
<head>
<title>Document Analysis Results</title>
</head>
<body>
<h1>Document Analysis Results</h1>
<p>FileName: {{ file_name }}</p>
<p>Total Pages: {{ page_count }}</p>
<p>Elapsed Time: {{ elapsed_time }}</p>
<p>Total TextArray count: {{ total_array_count }}</p>
<h2>Page Texts:</h2>
{% for item in page_texts %}
<p><b>Page {{ item.page_number }}:</b> {{ item.text }}</p>
{% endfor %}
</body>
</html>
<p><b>Page 1:</b> (목 차)</p>
<p><b>Page 1:</b> 제1장 총칙 제 1 조 [목적]</p>
<p><b>Page 1:</b> 제 2 조 [적용범위]</p>
<p><b>Page 1:</b> 제 3 조 [사원의 정의]</p>
<p><b>Page 1:</b> 제2장 인사 제1절 통칙 제 4 조 [채용 조건]</p>
<p><b>Page 1:</b> 제 5 조 [채용 고시]</p>
<p><b>Page 1:</b> 제 6 조 [계열/직계/직급의 구분]</p>
<p><b>Page 1:</b> 제 6 조의 2 [2000. 1. 1. 삭제]</p>
{
"status": "processing",
"result": null,
"start_time": "2024-06-04T08:54:17.886368",
"elapsed_time": "0:01:20.500081"
}
{
"status": "completed",
"start_time": "2024-06-04T08:54:17.902006",
"elapsed_time": "0:02:29.578560",
"result": {
"file_name": "1. 취업규칙.docx",
"start_time": "2024-06-04T08:54:17.902006",
"elapsed_time": "0:01:37.797150",
"contents": [
{
"text": "(목 차)",
"page_number": 1
},
{
"text": "제1장 총칙 제 1 조 [목적]",
"page_number": 1
},
{
"text": "제 2 조 [적용범위]",
"page_number": 1
},
{
...................
},
}
{
"detail": [
{
"loc": ["body", 0],
"msg": "파일이 필요합니다.",
"type": "value_error.missing"
}
]
}
import requests
url = 'http://20.39.188.204:8000/upload/'
files = {'file': open('yourfile.docx', 'rb')}
headers = {'access_token': '7f53a88b-b3d0-4a97-911b-xxxxxxx'}
response = requests.post(url, files=files, headers=headers)
print(response.text)
curl -X POST http://20.39.188.204:8000/upload/
-H "access_token: 7f53a88b-b3d0-4a97-911b-xxxxxxx"
-F "file=@/path/to/yourfile.docx"
const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');
const form = new FormData();
form.append('file', fs.createReadStream('/path/to/yourfile.docx'));
axios.post('http://20.39.188.204:8000/upload/', form, {
headers: {
...form.getHeaders(),
'access_token': '7f53a88b-b3d0-4a97-911b-xxxxxxxxx'
}
}).then(response => {
console.log(response.data);
}).catch(error => {
console.error('Upload failed:', error.response.data);
});
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.HttpMultipartMode;
import org.apache.http.entity.mime.content.FileBody;
import java.io.File;
public class FileUploader {
public static void main(String[] args) throws IOException {
CloseableHttpClient client = HttpClients.createDefault();
HttpPost httpPost = new HttpPost("http://20.39.188.204:8000/upload/");
File file = new File("/path/to/yourfile.docx");
FileBody fileBody = new FileBody(file, ContentType.DEFAULT_BINARY);
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
builder.addPart("file", fileBody);
httpPost.setEntity(builder.build());
httpPost.setHeader("access_token", "7f53a88b-b3d0-4a97-911b-xxxxxxx");
CloseableHttpResponse response = client.execute(httpPost);
try {
System.out.println(EntityUtils.toString(response.getEntity()));
} finally {
response.close();
}
}
}
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using System.IO;
class Program
{
static async Task Main(string[] args)
{
var filePath = @"C:\path\to\your\file.docx"; // 파일 경로 지정
var url = "http://20.39.188.204:8000/upload/"; // 서버의 URL
var apiKey = "YOUR_ACCESS_TOKEN"; // API 키 값
using (var client = new HttpClient())
{
using (var content = new MultipartFormDataContent())
{
// 파일을 멀티파트 폼 데이터로 추가
var fileContent = new ByteArrayContent(File.ReadAllBytes(filePath));
fileContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "\"file\"",
FileName = "\"" + Path.GetFileName(filePath) + "\""
};
fileContent.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
content.Add(fileContent);
// API 키를 요청 헤더에 추가
client.DefaultRequestHeaders.Add("access_token", apiKey);
try
{
// 요청 보내기
HttpResponseMessage response = await client.PostAsync(url, content);
if (response.IsSuccessStatusCode)
{
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine("Response Body: " + responseBody);
}
else
{
Console.WriteLine("Failed to upload. Status code: " + response.StatusCode);
}
}
catch (Exception ex)
{
Console.WriteLine("Exception caught: " + ex.ToString());
}
}
}
}
}