Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change urls. Add /api page #65

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion search/tests/test_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ class TestUrls(TestCase):
def test_graphql_endpoint(self):
data = {"query": "query {\n __typename\n}", "variables": None}
response = self.client.post(
"/api/graphql/", data, content_type="application/json"
"/api/search/graphql/", data, content_type="application/json"
)
self.assertEqual(response.status_code, 200)
2 changes: 1 addition & 1 deletion search/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
)

urlpatterns = [
path("", include(router.urls)),
path("rest/", include(router.urls)),
path("graphql/", csrf_exempt(GraphQLView.as_view(graphiql=True))),
]
2 changes: 1 addition & 1 deletion warsawlo/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [os.path.join(BASE_DIR, "templates")],
"DIRS": [os.path.join(BASE_DIR, "warsawlo/templates")],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
Expand Down
72 changes: 72 additions & 0 deletions warsawlo/templates/api.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<!doctype html>
<html lang="pl">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>WarsawLO API</title>
<style>
body {
padding: 0;
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}

.container {
width: 60%;
margin: 10vh auto 0 auto;
}

li {
padding: 0.3rem 0;
}

.warning {
display: inline-block;
margin: 1rem 0;
padding: 0.5rem;
border-radius: 5px;
border: 2px solid #f6e58d;
font-weight: bold;
line-height: 1.5rem;
}
a, a:visited{
color: black;
}

@media (max-width: 450px) {
.container {
width: calc(100% - 2rem);
}
}
</style>
</head>
<body>
<div class="container">
<h1>WarsawLO API</h1>
<span class="warning">
While we share our API, it is primarily intended for internal use. <br />
The API schema is subject to change without notice.
</span>
<p>Explore our APIs:</p>
<ul>
<li>
Search
<ul>
<li>
<a href="/api/search/graphql/">GraphQL API</a>
</li>
<li>
<a href="/api/search/rest/">REST API</a> (maintenance only)
</li>
</ul>
</li>
</ul>
<br />
<p>
More info on <a href="https://github.com/warsawlo/warsawlo-django">GitHub</a>
</p>
</div>
</body>
</html>
6 changes: 4 additions & 2 deletions warsawlo/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@
"""
from django.contrib import admin
from django.urls import include, path
from django.views.generic import TemplateView
from rest_framework.schemas import get_schema_view

urlpatterns = [
path("api/", include("search.urls")),
path("api/", TemplateView.as_view(template_name="api.html")),
path("api/search/", include("search.urls")),
path("admin/", admin.site.urls),
path(
"openapi/",
get_schema_view(
title="WarsaawLO", description="API for search", version="1.0.0"
title="WarsawLO", description="API for search", version="1.0.0"
),
name="openapi-schema",
),
Expand Down