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

Ahmed Amer #83

Open
wants to merge 10 commits into
base: main
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
1 change: 1 addition & 0 deletions Metal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Attitude by Metallica
20 changes: 5 additions & 15 deletions config/urls.py
Original file line number Diff line number Diff line change
@@ -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),
]
25 changes: 25 additions & 0 deletions headless/controllers.py
Original file line number Diff line number Diff line change
@@ -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)
5 changes: 3 additions & 2 deletions headless/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def get_post(title):
except FileNotFoundError:
return None


def del_post(title):
pass
filename = f"posts/{title}.md"
if default_storage.exists(filename):
default_storage.delete(filename)
4 changes: 2 additions & 2 deletions posts/dot_net_core_sucks_less_than_php.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Main title

Because I said so
الزعفرانية محور الكون

## Secondary title

I insist
I love Primer(Movie)
2 changes: 1 addition & 1 deletion posts/php_sucks.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
PHP sucks because Layth said so!
RINGS ARE COOL ASF
1 change: 1 addition & 0 deletions posts/test.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
do a flip
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ pydantic==1.8.2
pytz==2021.3
sqlparse==0.4.2
typing-extensions==3.10.0.2