Spaces:
Runtime error
Runtime error
Beamlnwza commited on
Commit ·
4bc041d
0
Parent(s):
init
Browse files- __pycache__/main.cpython-310.pyc +0 -0
- main.py +17 -0
- routes/__init__.py +0 -0
- routes/__pycache__/__init__.cpython-310.pyc +0 -0
- routes/__pycache__/api.cpython-310.pyc +0 -0
- routes/api.py +6 -0
- src/__init__.py +0 -0
- src/__pycache__/__init__.cpython-310.pyc +0 -0
- src/endpoints/__init__.py +0 -0
- src/endpoints/__pycache__/__init__.cpython-310.pyc +0 -0
- src/endpoints/__pycache__/generate.cpython-310.pyc +0 -0
- src/endpoints/__pycache__/view.cpython-310.pyc +0 -0
- src/endpoints/generate.py +17 -0
- src/endpoints/view.py +17 -0
- src/models/__init__.py +0 -0
- test_main.http +11 -0
__pycache__/main.cpython-310.pyc
ADDED
|
Binary file (506 Bytes). View file
|
|
|
main.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
from fastapi.middleware.cors import CORSMiddleware
|
| 3 |
+
from routes.api import router as api_router
|
| 4 |
+
|
| 5 |
+
app = FastAPI()
|
| 6 |
+
|
| 7 |
+
origins = ["http://localhost:5000"]
|
| 8 |
+
|
| 9 |
+
app.add_middleware(
|
| 10 |
+
CORSMiddleware,
|
| 11 |
+
allow_origins=origins,
|
| 12 |
+
allow_credentials=True,
|
| 13 |
+
allow_methods=["*"],
|
| 14 |
+
allow_headers=["*"],
|
| 15 |
+
)
|
| 16 |
+
|
| 17 |
+
app.include_router(api_router)
|
routes/__init__.py
ADDED
|
File without changes
|
routes/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (158 Bytes). View file
|
|
|
routes/__pycache__/api.cpython-310.pyc
ADDED
|
Binary file (315 Bytes). View file
|
|
|
routes/api.py
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import APIRouter
|
| 2 |
+
from src.endpoints import generate, view
|
| 3 |
+
|
| 4 |
+
router = APIRouter()
|
| 5 |
+
router.include_router(generate.router)
|
| 6 |
+
router.include_router(view.router)
|
src/__init__.py
ADDED
|
File without changes
|
src/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (155 Bytes). View file
|
|
|
src/endpoints/__init__.py
ADDED
|
File without changes
|
src/endpoints/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (165 Bytes). View file
|
|
|
src/endpoints/__pycache__/generate.cpython-310.pyc
ADDED
|
Binary file (613 Bytes). View file
|
|
|
src/endpoints/__pycache__/view.cpython-310.pyc
ADDED
|
Binary file (601 Bytes). View file
|
|
|
src/endpoints/generate.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import APIRouter
|
| 2 |
+
|
| 3 |
+
router = APIRouter(
|
| 4 |
+
prefix="/generate",
|
| 5 |
+
tags=["Generate"],
|
| 6 |
+
responses={404: {"description": "Not found"}},
|
| 7 |
+
)
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
@router.get("/")
|
| 11 |
+
async def info():
|
| 12 |
+
return {"info": "This is the generate endpoint"}
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
@router.get("/status")
|
| 16 |
+
async def status():
|
| 17 |
+
return {"status": "OK"}
|
src/endpoints/view.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import APIRouter
|
| 2 |
+
|
| 3 |
+
router = APIRouter(
|
| 4 |
+
prefix="/view",
|
| 5 |
+
tags=["View"],
|
| 6 |
+
responses={404: {"description": "Not found"}},
|
| 7 |
+
)
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
@router.get("/")
|
| 11 |
+
async def info():
|
| 12 |
+
return {"info": "This is the generate endpoint"}
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
@router.get("/status")
|
| 16 |
+
async def status():
|
| 17 |
+
return {"status": "OK"}
|
src/models/__init__.py
ADDED
|
File without changes
|
test_main.http
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Test your FastAPI endpoints
|
| 2 |
+
|
| 3 |
+
GET http://127.0.0.1:8000/
|
| 4 |
+
Accept: application/json
|
| 5 |
+
|
| 6 |
+
###
|
| 7 |
+
|
| 8 |
+
GET http://127.0.0.1:8000/hello/User
|
| 9 |
+
Accept: application/json
|
| 10 |
+
|
| 11 |
+
###
|