Skip to content

Commit

Permalink
Merge pull request #258 from bounswe/change-api-directories
Browse files Browse the repository at this point in the history
Change api directories
  • Loading branch information
higurbuzz authored May 28, 2023
2 parents 15e8874 + a279990 commit 7a16a8b
Show file tree
Hide file tree
Showing 17 changed files with 42 additions and 34 deletions.
6 changes: 5 additions & 1 deletion practice-app/client/pages/_document.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { Html, Head, Main, NextScript } from 'next/document'


export default function Document() {
return (
<Html lang="en">
<Head />
<Head >
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests" />

</Head>
<body>
<Main />
<NextScript />
Expand Down
4 changes: 0 additions & 4 deletions practice-app/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ services:
- client
networks:
- practice-network
volumes:
# - ~/static:/static
- ~/staticFiles:/root/staticFiles
restart: always

backend:
build:
context: ./server
Expand Down
2 changes: 1 addition & 1 deletion practice-app/server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ COPY requirements.txt .
RUN pip3 install -r requirements.txt
COPY . /app

CMD uvicorn main:app --host 0.0.0.0 --port 8000
CMD uvicorn main:app --host 0.0.0.0 --port 8000 --root-path /api
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
object[key] = value;
});
const json = JSON.stringify(object);
fetch('/addel/add/action', {
fetch('/api/addel/add/action', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
object[key] = value;
});
const json = JSON.stringify(object);
fetch('/addel/add/event', {
fetch('/api/addel/add/event', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
object[key] = value;
});
const json = JSON.stringify(object);
fetch('/addel/add/need', {
fetch('/api/addel/add/need', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
object[key] = value;
});
const json = JSON.stringify(object);
fetch('/addel/add/resource', {
fetch('/api/addel/add/resource', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</style>
</head>
<body>
<form action="/addel/delete/action">
<form action="/api/addel/delete/action">
<input type="text" name="id" placeholder="ID">
<input type="submit" value="Delete">
</form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</style>
</head>
<body>
<form action="/addel/delete/event">
<form action="/api/addel/delete/event">
<input type="text" name="id" placeholder="ID">
<input type="submit" value="Delete">
</form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</style>
</head>
<body>
<form action="/addel/delete/need">
<form action="/api/addel/delete/need">
<input type="text" name="id" placeholder="ID">
<input type="submit" value="Delete">
</form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</style>
</head>
<body>
<form action="/addel/delete/resource">
<form action="/api/addel/delete/resource">
<input type="text" name="id" placeholder="ID">
<input type="submit" value="Delete">
</form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
</style>
</head>
<body>
<form action="/addel/get/action">
<form action="/api/addel/get/action">
<input type="text" name="id" placeholder="ID">
<input type="submit" value="Get">
</form>
<form action="/addel/get/action">
<form action="/api/addel/get/action">
<input type=submit value="List">
</form>
</body>
Expand Down
4 changes: 2 additions & 2 deletions practice-app/server/add_activity_api/templates/get_event.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
</style>
</head>
<body>
<form action="/addel/get/event">
<form action="/api/addel/get/event">
<input type="text" name="id" placeholder="ID">
<input type="submit" value="Get">
</form>
<form action="/addel/get/event">
<form action="/api/addel/get/event">
<input type=submit value="List">
</form>
</body>
Expand Down
4 changes: 2 additions & 2 deletions practice-app/server/add_activity_api/templates/get_need.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
</style>
</head>
<body>
<form action="/addel/get/need">
<form action="/api/addel/get/need">
<input type="text" name="id" placeholder="ID">
<input type="submit" value="Get">
</form>
<form action="/addel/get/need">
<form action="/api/addel/get/need">
<input type=submit value="List">
</form>
</body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
</style>
</head>
<body>
<form action="/addel/get/resource">
<form action="/api/addel/get/resource">
<input type="text" name="id" placeholder="ID">
<input type="submit" value="Get">
</form>
<form action="/addel/get/resource">
<form action="/api/addel/get/resource">
<input type=submit value="List">
</form>
</body>
Expand Down
24 changes: 12 additions & 12 deletions practice-app/server/add_activity_api/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,50 +59,50 @@
<body>
<div class="button-group-holder">
<h1>Add Activity</h1>
<form action="/addel/add" method="get" class="form">
<form action="/api/addel/add" method="get" class="form">
<input type="hidden" name="name" value="resource">
<button type="submit" class="button">Add Resource</button>
</form>
<form action="/addel/add" method="get" class="form">
<form action="/api/addel/add" method="get" class="form">
<input type="hidden" name="name" value="need">
<button type="submit" class="button">Add Need</button>
</form>
<form action="/addel/add" method="get" class="form">
<form action="/api/addel/add" method="get" class="form">
<input type="hidden" name="name" value="event">
<button type="submit" class="button">Add Event</button>
</form>
<form action="/addel/add" method="get" class="form">
<form action="/api/addel/add" method="get" class="form">
<input type="hidden" name="name" value="action">
<button type="submit" class="button">Add Action</button>
</form>
</div>
<div class="button-group-holder">
<h1>Get Activity</h1>
<form action="/addel/get/resource/ui" class="form">
<form action="/api/addel/get/resource/ui" class="form">
<button type="submit" class="button">Get Resource</button>
</form>
<form action="/addel/get/need/ui" class="form">
<form action="/api/addel/get/need/ui" class="form">
<button type="submit" class="button">Get Need</button>
</form>
<form action="/addel/get/event/ui" class="form">
<form action="/api/addel/get/event/ui" class="form">
<button type="submit" class="button">Get Event</button>
</form>
<form action="/addel/get/action/ui" class="form">
<form action="/api/addel/get/action/ui" class="form">
<button type="submit" class="button">Get Action</button>
</form>
</div>
<div class="button-group-holder">
<h1>Delete Activity</h1>
<form action="/addel/delete/resource/ui" class="form">
<form action="/api/addel/delete/resource/ui" class="form">
<button type="submit" class="button">Delete Resource</button>
</form>
<form action="/addel/delete/need/ui" class="form">
<form action="/api/addel/delete/need/ui" class="form">
<button type="submit" class="button">Delete Need</button>
</form>
<form action="/addel/delete/event/ui" class="form">
<form action="/api/addel/delete/event/ui" class="form">
<button type="submit" class="button">Delete Event</button>
</form>
<form action="/addel/delete/action/ui" class="form">
<form action="/api/addel/delete/action/ui" class="form">
<button type="submit" class="button">Delete Action</button>
</form>
</div>
Expand Down
8 changes: 8 additions & 0 deletions practice-app/server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@

app = FastAPI()
app.include_router(add_activity_app)
@app.get("/docs", include_in_schema=False)
async def custom_swagger_ui_html(req):
root_path = req.scope.get("root_path", "").rstrip("/")
openapi_url = root_path+ 'api/' + app.openapi_url
return get_swagger_ui_html(
openapi_url=openapi_url,
title="API",
)

app.add_middleware(
CORSMiddleware,
Expand Down

0 comments on commit 7a16a8b

Please sign in to comment.