Spaces:
Runtime error
Runtime error
David Li commited on
Commit ·
3739de4
1
Parent(s): ca73f58
fix: deploy again
Browse files- .gitignore +2 -1
- app.py +10 -0
- diff.txt +0 -92
- requirements.txt +2 -1
.gitignore
CHANGED
|
@@ -128,4 +128,5 @@ dmypy.json
|
|
| 128 |
# Pyre type checker
|
| 129 |
.pyre/
|
| 130 |
|
| 131 |
-
.deta
|
|
|
|
|
|
| 128 |
# Pyre type checker
|
| 129 |
.pyre/
|
| 130 |
|
| 131 |
+
.deta
|
| 132 |
+
diff.txt
|
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
from fastapi import FastAPI
|
| 2 |
import pandas as pd
|
| 3 |
import os
|
|
|
|
| 4 |
from deta import Deta
|
| 5 |
from fastapi.responses import StreamingResponse, FileResponse
|
| 6 |
from io import BytesIO
|
|
@@ -50,3 +51,12 @@ async def get_file(id: str):
|
|
| 50 |
res = drive.get(id)
|
| 51 |
return StreamingResponse(res.iter_chunks(1024), media_type="application/pdf")
|
| 52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from fastapi import FastAPI
|
| 2 |
import pandas as pd
|
| 3 |
import os
|
| 4 |
+
import requests
|
| 5 |
from deta import Deta
|
| 6 |
from fastapi.responses import StreamingResponse, FileResponse
|
| 7 |
from io import BytesIO
|
|
|
|
| 51 |
res = drive.get(id)
|
| 52 |
return StreamingResponse(res.iter_chunks(1024), media_type="application/pdf")
|
| 53 |
|
| 54 |
+
|
| 55 |
+
# app get https://raw.githubusercontent.com/FriendlyUser/chatgpt_prompts/main/README.md
|
| 56 |
+
# and return text
|
| 57 |
+
@app.get("/chatgpt/README")
|
| 58 |
+
async def get_readme():
|
| 59 |
+
# requests get data from url
|
| 60 |
+
readMe = requests.get("https://raw.githubusercontent.com/FriendlyUser/chatgpt_prompts/main/README.md")
|
| 61 |
+
# return text
|
| 62 |
+
return readMe.text
|
diff.txt
DELETED
|
@@ -1,92 +0,0 @@
|
|
| 1 |
-
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
|
| 2 |
-
index 0aa8d59..083dc56 100644
|
| 3 |
-
--- a/.github/workflows/deploy.yml
|
| 4 |
-
+++ b/.github/workflows/deploy.yml
|
| 5 |
-
@@ -5,6 +5,10 @@ jobs:
|
| 6 |
-
deploy:
|
| 7 |
-
runs-on: ubuntu-latest
|
| 8 |
-
steps:
|
| 9 |
-
+ - run:
|
| 10 |
-
+ name: "mv file"
|
| 11 |
-
+ command: |
|
| 12 |
-
+ mv app.py main.py
|
| 13 |
-
- uses: actions/checkout@v2 #Be sure you check-out the repo first. Deta CLI needs access to the files
|
| 14 |
-
- uses: BogDAAAMN/deta-deploy-action@v1.0.1
|
| 15 |
-
with:
|
| 16 |
-
diff --git a/ReadMe.md b/ReadMe.md
|
| 17 |
-
index a791671..8ec842b 100644
|
| 18 |
-
--- a/ReadMe.md
|
| 19 |
-
+++ b/ReadMe.md
|
| 20 |
-
@@ -1,3 +1,14 @@
|
| 21 |
-
+---
|
| 22 |
-
+title: Hs Fast Api
|
| 23 |
-
+emoji: 🐢
|
| 24 |
-
+colorFrom: red
|
| 25 |
-
+colorTo: blue
|
| 26 |
-
+sdk: docker
|
| 27 |
-
+pinned: false
|
| 28 |
-
+license: openrail
|
| 29 |
-
+port: 8000
|
| 30 |
-
+---
|
| 31 |
-
+
|
| 32 |
-
# fast-rapidapi
|
| 33 |
-
Simple fastapi hosted on deta for rapidapi
|
| 34 |
-
|
| 35 |
-
diff --git a/main.py b/main.py
|
| 36 |
-
deleted file mode 100644
|
| 37 |
-
index f496628..0000000
|
| 38 |
-
--- a/main.py
|
| 39 |
-
+++ /dev/null
|
| 40 |
-
@@ -1,52 +0,0 @@
|
| 41 |
-
-from fastapi import FastAPI
|
| 42 |
-
-import pandas as pd
|
| 43 |
-
-import os
|
| 44 |
-
-from deta import Deta
|
| 45 |
-
-from fastapi.responses import StreamingResponse, FileResponse
|
| 46 |
-
-from io import BytesIO
|
| 47 |
-
-
|
| 48 |
-
-from fastapi.middleware.cors import CORSMiddleware
|
| 49 |
-
-
|
| 50 |
-
-app = FastAPI()
|
| 51 |
-
-
|
| 52 |
-
-# load deta using
|
| 53 |
-
-project_key = os.getenv("DETA_DRIVE_KEY")
|
| 54 |
-
-deta = Deta(project_key)
|
| 55 |
-
-drive = deta.Drive("stonk_events")
|
| 56 |
-
-
|
| 57 |
-
-app.add_middleware(
|
| 58 |
-
- CORSMiddleware,
|
| 59 |
-
- allow_origins=["*"],
|
| 60 |
-
- allow_credentials=True,
|
| 61 |
-
- allow_methods=["*"],
|
| 62 |
-
- allow_headers=["*"],
|
| 63 |
-
-)
|
| 64 |
-
-
|
| 65 |
-
-@app.get("/files")
|
| 66 |
-
-async def get_files(exchange: str = "US"):
|
| 67 |
-
- """
|
| 68 |
-
- """
|
| 69 |
-
- # get files in deta
|
| 70 |
-
- result = drive.list()
|
| 71 |
-
- all_files = result.get("names")
|
| 72 |
-
- paging = result.get("paging")
|
| 73 |
-
- last = paging.get("last") if paging else None
|
| 74 |
-
-
|
| 75 |
-
- while (last):
|
| 76 |
-
- # provide last from previous call
|
| 77 |
-
- result = drive.list(last=last)
|
| 78 |
-
-
|
| 79 |
-
- all_files += result.get("names")
|
| 80 |
-
- # update last
|
| 81 |
-
- paging = result.get("paging")
|
| 82 |
-
- last = paging.get("last") if paging else None
|
| 83 |
-
- return all_files
|
| 84 |
-
-
|
| 85 |
-
-
|
| 86 |
-
-# get file by name from deta /file/{id}
|
| 87 |
-
-# reason it was likely failing is because of the response size limit
|
| 88 |
-
-@app.get("/file/{id}")
|
| 89 |
-
-async def get_file(id: str):
|
| 90 |
-
- res = drive.get(id)
|
| 91 |
-
- return StreamingResponse(res.iter_chunks(1024), media_type="application/pdf")
|
| 92 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
requirements.txt
CHANGED
|
@@ -1,3 +1,4 @@
|
|
| 1 |
fastapi
|
| 2 |
pandas
|
| 3 |
-
deta
|
|
|
|
|
|
| 1 |
fastapi
|
| 2 |
pandas
|
| 3 |
+
deta
|
| 4 |
+
requests
|