dakunesu commited on
Commit
e0719ac
1 Parent(s): a206c92

Synced repo using 'sync_with_huggingface' Github Action

Browse files
Files changed (5) hide show
  1. .env.example +2 -0
  2. Dockerfile +17 -0
  3. app.py +9 -0
  4. neo.py +52 -0
  5. requirements.txt +35 -0
.env.example ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ NEO_EMAIL=
2
+ NEO_PASSWORD=
Dockerfile ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # fastapi
2
+ FROM tiangolo/uvicorn-gunicorn-fastapi:python3.8
3
+
4
+ # Set working directory
5
+ WORKDIR /app
6
+
7
+ # Copy the current directory contents into the container at /app
8
+ COPY . /app
9
+
10
+ # Install any needed packages specified in requirements.txt
11
+ RUN pip install --no-cache-dir -r requirements.txt
12
+
13
+ # Make port available to the world outside this container
14
+ EXPOSE 7860
15
+
16
+ # Run app.py when the container launches
17
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
app.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI, UploadFile, File
2
+
3
+ app = FastAPI()
4
+
5
+ @app.put("/upload")
6
+ async def upload_file(file: UploadFile = File(...)):
7
+ contents = await file.read()
8
+ # Now you have the file contents, you can save it or process it as needed
9
+ return {"filename": file.filename}
neo.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ import uuid
3
+ import time
4
+ import os
5
+ import urllib3
6
+ from dotenv import load_dotenv
7
+
8
+ load_dotenv()
9
+
10
+ urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
11
+
12
+ EMAIL = os.getenv("NEO_EMAIL")
13
+ PASSWORD = os.getenv("NEO_PASSWORD")
14
+
15
+
16
+ class NeoCloud:
17
+ def __init__(self):
18
+ self.session = requests.Session()
19
+ self.session.headers["X-Requested-With"] = "XMLHttpRequest"
20
+ self.session.cookies["ci_session"] = self.login(EMAIL, PASSWORD)
21
+
22
+ def login(self, email, password):
23
+ url = "https://neocloud.co.in/authenticate/verifyLogin"
24
+ form = {
25
+ "lg_email": (None, email),
26
+ "lg_password": (None, password),
27
+ "lg_remember_me": (None, ""),
28
+ "csrf_neocloud": (None, ""),
29
+ }
30
+
31
+ r = requests.post(
32
+ url, files=form, headers={"X-Requested-With": "XMLHttpRequest"}
33
+ )
34
+ cookies = r.cookies.get_dict()
35
+ return cookies["ci_session"]
36
+
37
+ def get_presigned_url(self, filename=None, extension="bin"):
38
+ url = "https://neocloud.co.in/Ajax/getPresignedUrl"
39
+ timestamp = str(int(time.time()))
40
+ key = f"neoupload/{timestamp}/{filename or str(uuid.uuid4())}.{extension}"
41
+ form = {
42
+ "key": (None, key),
43
+ "csrf_neocloud": (None, ""),
44
+ }
45
+
46
+ r = self.session.post(url, files=form)
47
+ return r.json()["url"]
48
+
49
+
50
+ if __name__ == "__main__":
51
+ neo = NeoCloud()
52
+ print(neo.get_presigned_url())
requirements.txt ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ annotated-types==0.6.0
2
+ anyio==4.3.0
3
+ certifi==2024.2.2
4
+ charset-normalizer==3.3.2
5
+ click==8.1.7
6
+ dnspython==2.6.1
7
+ email_validator==2.1.1
8
+ exceptiongroup==1.2.1
9
+ fastapi==0.110.2
10
+ h11==0.14.0
11
+ httpcore==1.0.5
12
+ httptools==0.6.1
13
+ httpx==0.27.0
14
+ idna==3.7
15
+ itsdangerous==2.2.0
16
+ Jinja2==3.1.3
17
+ MarkupSafe==2.1.5
18
+ orjson==3.10.1
19
+ pydantic==2.7.0
20
+ pydantic-extra-types==2.6.0
21
+ pydantic-settings==2.2.1
22
+ pydantic_core==2.18.1
23
+ python-dotenv==1.0.1
24
+ python-multipart==0.0.9
25
+ PyYAML==6.0.1
26
+ requests==2.31.0
27
+ sniffio==1.3.1
28
+ starlette==0.37.2
29
+ typing_extensions==4.11.0
30
+ ujson==5.9.0
31
+ urllib3==2.2.1
32
+ uvicorn==0.29.0
33
+ uvloop==0.19.0
34
+ watchfiles==0.21.0
35
+ websockets==12.0