abadesalex commited on
Commit
54bac2e
1 Parent(s): 51c67cb

reestructre

Browse files
Files changed (5) hide show
  1. , +0 -0
  2. Dockerfile +2 -1
  3. FastAPI/app/api.py +27 -0
  4. FastAPI/app/main.py +4 -11
  5. my-app/src/App.js +1 -1
, ADDED
File without changes
Dockerfile CHANGED
@@ -14,4 +14,5 @@ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
14
  COPY ./FastAPI/app /code/app
15
 
16
  # Set the command to run the application using Uvicorn
17
- CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
 
 
14
  COPY ./FastAPI/app /code/app
15
 
16
  # Set the command to run the application using Uvicorn
17
+ # CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
18
+ CMD ["python", "main.py"]
FastAPI/app/api.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ from fastapi.staticfiles import StaticFiles
3
+ from fastapi.responses import FileResponse
4
+ from fastapi.middleware.cors import CORSMiddleware
5
+
6
+
7
+ app = FastAPI()
8
+
9
+ origins = [
10
+ "http://localhost:3000",
11
+ "localhost:3000",
12
+ "https://abadesalex-emb-rep.hf.space",
13
+ ]
14
+
15
+ app.add_middleware(
16
+ CORSMiddleware,
17
+ allow_origins=origins,
18
+ allow_credentials=True,
19
+ allow_methods=["*"],
20
+ allow_headers=["*"]
21
+ )
22
+
23
+ app.mount("/", StaticFiles(directory="app/build", html=True), name="static")
24
+
25
+ # @app.get("/")
26
+ # def index() -> FileResponse:
27
+ # return FileResponse(path="/app/build/index.html", media_type="text/html")
FastAPI/app/main.py CHANGED
@@ -1,12 +1,5 @@
1
- from fastapi import FastAPI
2
- from fastapi.staticfiles import StaticFiles
3
- from fastapi.responses import FileResponse
4
 
5
-
6
- app = FastAPI()
7
-
8
- app.mount("/", StaticFiles(directory="app/build", html=True), name="static")
9
-
10
- @app.get("/")
11
- def index() -> FileResponse:
12
- return FileResponse(path="/app/build/index.html", media_type="text/html")
 
1
+ import uvicorn
 
 
2
 
3
+ if __name__ == "__main__":
4
+ # This line tells uvicorn to run the app defined in app/api.py
5
+ uvicorn.run("app.api:app", host="0.0.0.0", port=8000, reload=True)
 
 
 
 
 
my-app/src/App.js CHANGED
@@ -16,7 +16,7 @@ function App() {
16
  setMessage('Pau chupapijas');
17
  // console.log("Word One: ", wordOne);
18
  // const url = "http://127.0.0.1:8000/test";
19
- // // const url = "https://abadesalex-emb-rep.hf.space/test";
20
  // const dataToSend = JSON.stringify({ message: wordOne });
21
  // fetch(url, {
22
  // method: "POST", // Specifying the method
 
16
  setMessage('Pau chupapijas');
17
  // console.log("Word One: ", wordOne);
18
  // const url = "http://127.0.0.1:8000/test";
19
+ const url = "https://abadesalex-emb-rep.hf.space/test";
20
  // const dataToSend = JSON.stringify({ message: wordOne });
21
  // fetch(url, {
22
  // method: "POST", // Specifying the method