Spaces:
Sleeping
Sleeping
switch to flask
Browse files- README.md +9 -8
- app.py +20 -6
- requirements.txt +2 -1
- start.py +3 -0
- static/index.html +28 -0
README.md
CHANGED
|
@@ -1,13 +1,14 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
-
|
| 9 |
-
|
| 10 |
license: mit
|
|
|
|
| 11 |
---
|
| 12 |
|
| 13 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces
|
|
|
|
| 1 |
---
|
| 2 |
+
title: open-in-overleaf
|
| 3 |
+
emoji: ⚡
|
| 4 |
+
colorFrom: green
|
| 5 |
+
colorTo: green
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 4.36.0
|
| 8 |
+
python_version: 3.10.4
|
| 9 |
+
app_file: start.py
|
| 10 |
license: mit
|
| 11 |
+
pinned: false
|
| 12 |
---
|
| 13 |
|
| 14 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces#reference
|
app.py
CHANGED
|
@@ -1,11 +1,16 @@
|
|
| 1 |
import io
|
|
|
|
|
|
|
| 2 |
import shutil
|
| 3 |
import tarfile
|
| 4 |
import tempfile
|
| 5 |
import uuid
|
|
|
|
| 6 |
|
| 7 |
-
import gradio as gr
|
| 8 |
import requests
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
|
| 11 |
def convert_tar_to_zip(arxiv_url):
|
|
@@ -25,11 +30,20 @@ def convert_tar_to_zip(arxiv_url):
|
|
| 25 |
zip_name = f'{filename}'
|
| 26 |
shutil.make_archive(filename, 'zip', temp_dir)
|
| 27 |
|
| 28 |
-
return
|
| 29 |
|
| 30 |
-
|
| 31 |
|
| 32 |
-
|
| 33 |
-
description = "Enter the URL of the Arxiv paper"
|
| 34 |
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import io
|
| 2 |
+
import json
|
| 3 |
+
import os
|
| 4 |
import shutil
|
| 5 |
import tarfile
|
| 6 |
import tempfile
|
| 7 |
import uuid
|
| 8 |
+
from io import BytesIO
|
| 9 |
|
|
|
|
| 10 |
import requests
|
| 11 |
+
from fastapi import FastAPI
|
| 12 |
+
from fastapi.responses import FileResponse, StreamingResponse
|
| 13 |
+
from fastapi.staticfiles import StaticFiles
|
| 14 |
|
| 15 |
|
| 16 |
def convert_tar_to_zip(arxiv_url):
|
|
|
|
| 30 |
zip_name = f'{filename}'
|
| 31 |
shutil.make_archive(filename, 'zip', temp_dir)
|
| 32 |
|
| 33 |
+
return f'{zip_name}.zip'
|
| 34 |
|
| 35 |
+
app = FastAPI(docs_url=None, redoc_url=None)
|
| 36 |
|
| 37 |
+
app.mount("/static", StaticFiles(directory="static"), name="static")
|
|
|
|
| 38 |
|
| 39 |
+
|
| 40 |
+
@app.head("/")
|
| 41 |
+
@app.get("/")
|
| 42 |
+
def index() -> FileResponse:
|
| 43 |
+
return FileResponse(path="static/index.html", media_type="text/html")
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
@app.get("/fetch_tar")
|
| 47 |
+
def t5(arxiv_url: str):
|
| 48 |
+
zip_path = convert_tar_to_zip(arxiv_url)
|
| 49 |
+
return FileResponse(path=zip_path, media_type="application/zip", filename=zip_path)
|
requirements.txt
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
|
|
| 1 |
requests==2.31.0
|
| 2 |
-
|
|
|
|
| 1 |
+
fastapi==0.74.*
|
| 2 |
requests==2.31.0
|
| 3 |
+
uvicorn[standard]==0.17.*
|
start.py
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import subprocess
|
| 2 |
+
|
| 3 |
+
subprocess.run("uvicorn app:app --host 0.0.0.0 --port 7860", shell=True)
|
static/index.html
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Open in Overleaf</title>
|
| 7 |
+
<style>
|
| 8 |
+
body {
|
| 9 |
+
margin: 0;
|
| 10 |
+
padding: 0;
|
| 11 |
+
display: flex;
|
| 12 |
+
justify-content: center;
|
| 13 |
+
align-items: center;
|
| 14 |
+
min-height: 100vh;
|
| 15 |
+
font-family: Arial, sans-serif;
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
h1 {
|
| 19 |
+
font-size: 4rem;
|
| 20 |
+
text-align: center;
|
| 21 |
+
}
|
| 22 |
+
</style>
|
| 23 |
+
</head>
|
| 24 |
+
|
| 25 |
+
<body>
|
| 26 |
+
<h1>Open in Overleaf</h1>
|
| 27 |
+
</body>
|
| 28 |
+
</html>
|