-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bd8b74b
commit 0d469de
Showing
11 changed files
with
459 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
__pycache__/ | ||
.vscode/ |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from fastapi import FastAPI | ||
|
||
from routers import pastes | ||
|
||
app = FastAPI() | ||
|
||
app.include_router(pastes.router) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from typing import List, Optional | ||
|
||
from pydantic import BaseModel | ||
|
||
__all__ = ("PasteCreate", "PasteEdit", "PasteDelete") | ||
|
||
|
||
class PasteCreate(BaseModel): | ||
content: str | ||
syntax: Optional[str] = None | ||
nick: Optional[str] = None | ||
|
||
|
||
class PasteEdit(BaseModel): | ||
new_content: str | ||
nick: Optional[str] = None | ||
|
||
|
||
class PasteDelete(BaseModel): | ||
pastes: List[str] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from secrets import token_urlsafe | ||
from typing import Dict | ||
|
||
from fastapi import APIRouter | ||
|
||
from models import * | ||
|
||
__all__ = ("post_paste", "raw_paste", "edit_paste") | ||
|
||
router = APIRouter() | ||
|
||
@router.post("/paste", tags=["pastes"]) | ||
async def post_paste(payload: PasteCreate) -> Dict[str, str]: | ||
""" Post a paste to MystBin. """ | ||
return {"pastes": [{"id": token_urlsafe(5), "nick": payload.nick}]} | ||
|
||
@router.get("/paste/{paste_id}", tags=["pastes"]) | ||
async def raw_paste(paste_id: str) -> Dict[str, str]: | ||
""" Get a raw paste from MystBin. """ | ||
return {"id": paste_id, "data": "Umbra sucks!"} | ||
|
||
@router.put("/paste/{paste_id}", tags=["pastes"]) | ||
@router.patch("/paste/{paste_id}", tags=["pastes"]) | ||
async def edit_paste(paste_id: str, payload: PasteEdit) -> Dict[str, str]: | ||
""" Edit a paste on MystBin. | ||
* Requires authentication. | ||
""" | ||
... | ||
|
||
@router.delete("/paste/{paste_id}", tags=["pastes"]) | ||
async def delete_paste(paste_id: str = None) -> Dict[str, str]: | ||
""" Deletes pastes on MystBin. | ||
* Requires authentication. | ||
""" | ||
return {"paste": paste_id} | ||
|
||
@router.delete("/paste", tags=["pastes"]) | ||
async def delete_pastes(payload: PasteDelete) -> Dict[str, str]: | ||
""" Deletes pastes on MystBin. | ||
* Requires authentication. | ||
""" | ||
return {"paste": payload} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[tool.poetry] | ||
name = "mystbin-rewrite" | ||
version = "0.1.0" | ||
description = "A rewrite of Mystbin!" | ||
authors = ["Pythonista Guild <#todo>"] | ||
license = "GPL-3.0" | ||
|
||
[tool.poetry.dependencies] | ||
python = "^3.8" | ||
ujson = "^4.0.1" | ||
asyncpg = "^0.21.0" | ||
fastapi = "^0.61.1" | ||
|
||
[tool.poetry.dev-dependencies] | ||
pylint = "^2.6.0" | ||
autopep8 = "^1.5.4" | ||
uvicorn = "^0.12.2" | ||
|
||
[build-system] | ||
requires = ["poetry-core>=1.0.0"] | ||
build-backend = "poetry.core.masonry.api" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fastapi==>=0.61.2 | ||
ujson==>=4.0.1 | ||
asyncpg==>=0.21.0 |