diff --git a/Metal.md b/Metal.md new file mode 100644 index 00000000..615d6a41 --- /dev/null +++ b/Metal.md @@ -0,0 +1 @@ +Attitude by Metallica diff --git a/config/urls.py b/config/urls.py index d52e5777..f77bccd3 100644 --- a/config/urls.py +++ b/config/urls.py @@ -1,21 +1,11 @@ -"""config URL Configuration - -The `urlpatterns` list routes URLs to views. For more information please see: - https://docs.djangoproject.com/en/3.2/topics/http/urls/ -Examples: -Function views - 1. Add an import: from my_app import views - 2. Add a URL to urlpatterns: path('', views.home, name='home') -Class-based views - 1. Add an import: from other_app.views import Home - 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') -Including another URLconf - 1. Import the include() function: from django.urls import include, path - 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) -""" from django.contrib import admin from django.urls import path +from headless.controllers import Management_Control +from ninja import NinjaAPI +api = NinjaAPI(title='Rings are cool man', description='I insist') +api.add_router("", Management_Control) urlpatterns = [ path('admin/', admin.site.urls), + path('api/', api.urls), ] diff --git a/headless/controllers.py b/headless/controllers.py index e69de29b..185ad4f9 100644 --- a/headless/controllers.py +++ b/headless/controllers.py @@ -0,0 +1,25 @@ +from urllib import request +from headless.utils import * +from ninja import Router + +Management_Control = Router() + +@Management_Control.get("/Listing_Posts") +def listing_posts(request): + return list_posts() + +@Management_Control.get("/Requesting_Post") +def calling_post(request,title: str): + return get_post(title) + +@Management_Control.post("/Creating_Post") +def make_post(request,title: str,content: str): + return save_post(title,content) + +@Management_Control.put("/Updating_Post") +def upating_post(request,title: str,content: str): + return save_post(title,content,) + +@Management_Control.delete("/Deleting_Post") +def remove_post(request,title): + return del_post(title) diff --git a/headless/utils.py b/headless/utils.py index 20a48f9c..6c9c436e 100644 --- a/headless/utils.py +++ b/headless/utils.py @@ -36,6 +36,7 @@ def get_post(title): except FileNotFoundError: return None - def del_post(title): - pass \ No newline at end of file + filename = f"posts/{title}.md" + if default_storage.exists(filename): + default_storage.delete(filename) diff --git a/posts/dot_net_core_sucks_less_than_php.md b/posts/dot_net_core_sucks_less_than_php.md index 9b8a873b..8fc974b6 100644 --- a/posts/dot_net_core_sucks_less_than_php.md +++ b/posts/dot_net_core_sucks_less_than_php.md @@ -1,7 +1,7 @@ # Main title -Because I said so +الزعفرانية محور الكون ## Secondary title -I insist \ No newline at end of file +I love Primer(Movie) diff --git a/posts/php_sucks.md b/posts/php_sucks.md index 56fa8623..c5b13b40 100644 --- a/posts/php_sucks.md +++ b/posts/php_sucks.md @@ -1 +1 @@ -PHP sucks because Layth said so! \ No newline at end of file +RINGS ARE COOL ASF diff --git a/posts/test.md b/posts/test.md new file mode 100644 index 00000000..ba6757f7 --- /dev/null +++ b/posts/test.md @@ -0,0 +1 @@ +do a flip \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index ac5d13a7..77296dfc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,3 +5,4 @@ pydantic==1.8.2 pytz==2021.3 sqlparse==0.4.2 typing-extensions==3.10.0.2 +