amirkiarafiei commited on
Commit
9d5a9f1
·
1 Parent(s): 43b11cc

initial project setup with FastAPI, Dockerfile, and README updates

Browse files
Files changed (6) hide show
  1. .gitignore +15 -0
  2. Dockerfile +16 -0
  3. README.md +24 -3
  4. app.py +7 -0
  5. main.py +9 -0
  6. requirements.txt +3 -0
.gitignore ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Byte-compiled files
2
+ __pycache__/
3
+ *.py[cod]
4
+
5
+ # Virtual environments
6
+ .env
7
+ .venv
8
+
9
+ # Distribution files
10
+ dist/
11
+ build/
12
+ *.egg-info/
13
+
14
+ # Logs
15
+ *.log
Dockerfile ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
2
+ # you will also find guides on how best to write your Dockerfile
3
+
4
+ FROM python:3.9
5
+
6
+ RUN useradd -m -u 1000 user
7
+ USER user
8
+ ENV PATH="/home/user/.local/bin:$PATH"
9
+
10
+ WORKDIR /app
11
+
12
+ COPY --chown=user ./requirements.txt requirements.txt
13
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
14
+
15
+ COPY --chown=user . /app
16
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
README.md CHANGED
@@ -1,5 +1,5 @@
1
  ---
2
- title: Github Hf Sync
3
  emoji: 📈
4
  colorFrom: purple
5
  colorTo: purple
@@ -8,5 +8,26 @@ pinned: false
8
  short_description: 'A Sample Space Synced with a GitHub Repository '
9
  ---
10
 
11
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
12
- # github-hf-sync
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ title: Github and Hugging Face Space Synchronization
3
  emoji: 📈
4
  colorFrom: purple
5
  colorTo: purple
 
8
  short_description: 'A Sample Space Synced with a GitHub Repository '
9
  ---
10
 
11
+ # Github and Hugging Face Synchronization
12
+ Welcome! This project shows you how to develop your app (like a chatbot) in GitHub and automatically sync it to a Hugging Face Space to host it online. For a detailed step-by-step guide with pictures, check out our [Medium article](something). Let’s get your app live easily!.
13
+
14
+ ### Requirements
15
+
16
+ - `Python 3.9`
17
+ - `pip install -r requirements.txt`
18
+
19
+ ### How to send a GET request to the Hugging Face Space endpoint
20
+
21
+ The Hugging Face Space endpoint of this project is `https://amirkiarafiei-github-hf-sync.hf.space/`.
22
+ You can either:
23
+ - Send a curl request in your terminal:
24
+
25
+ ```bash
26
+ curl -s GET https://amirkiarafiei-github-hf-sync.hf.space/
27
+ ```
28
+
29
+ - Or run the `main.py`:
30
+
31
+ ```bash
32
+ python main.py
33
+ ```
app.py ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+
3
+ app = FastAPI()
4
+
5
+ @app.get("/")
6
+ def greet_json():
7
+ return {"Hello": "World!"}
main.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+
3
+ if __name__ == '__main__':
4
+ # URL of the Hugging Face Space endpoint
5
+ url = "https://amirkiarafiei-github-hf-sync.hf.space/"
6
+
7
+ # Send a GET request and print the response
8
+ response = requests.get(url)
9
+ print(response.text)
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ fastapi
2
+ uvicorn[standard]
3
+ requests