-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2024-07-10 17:11:06.924230 new snippets
- Loading branch information
1 parent
6ce6848
commit 9879271
Showing
17 changed files
with
683 additions
and
698 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
This file was deleted.
Oops, something went wrong.
This file was deleted.
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,56 @@ | ||
#date: 2024-07-10T16:53:49Z | ||
#url: https://api.github.com/gists/71ba97cd59962409e1eb4d5dd0f3e208 | ||
#owner: https://api.github.com/users/Nyashyker | ||
|
||
from pprint import pprint | ||
from pathlib import Path | ||
|
||
# https://python-telegraph.readthedocs.io/en/latest/telegraph.html | ||
import telegraph | ||
|
||
|
||
def setContent(pictures: list) -> list: | ||
content: list = [] | ||
for pic in pictures: | ||
content.append( | ||
{ | ||
"tag": "figure", | ||
"children": [ | ||
{"tag": "img", "attrs": {"src": pic}}, | ||
{"tag": "figcaption", "children": [""]}, | ||
], | ||
} | ||
) | ||
return content | ||
|
||
|
||
def uploadPictures(folder: Path) -> list[str]: | ||
""" | ||
Працює тільки з .jpg | ||
""" | ||
|
||
pictures: list = [] | ||
for img in folder.glob("*.jpg"): | ||
pictures.append(TG.upload_file(img)[0]["src"]) | ||
|
||
return pictures | ||
|
||
|
||
TG = telegraph.api.Telegraph( | ||
"5fc3709d100f62b276ec573a389a11ea267692f67f6999e4568426a9105d" | ||
) | ||
# TG.create_account("DP", "Даєш переклад!") | ||
# print(TG.get_access_token(), end= "**********" | ||
|
||
path = Path | ||
pictures: list[str] = uploadPictures() | ||
|
||
# result = TG.edit_page( | ||
result = TG.create_page( | ||
# path="", | ||
title="TestTestTest", | ||
content=setContent(pictures), | ||
author_name="", | ||
author_url="", | ||
) | ||
pprint(result) |
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,33 @@ | ||
//date: 2024-07-10T16:55:53Z | ||
//url: https://api.github.com/gists/3ee12b530dc49c2dc093fc53e89d4427 | ||
//owner: https://api.github.com/users/BK1031 | ||
|
||
package main | ||
|
||
import ( | ||
"net/http" | ||
"time" | ||
|
||
"github.com/gin-gonic/gin" | ||
) | ||
|
||
var Port = "9000" | ||
|
||
func StartServer() { | ||
r := gin.Default() | ||
r.GET("/ecu", GetAllECUs) | ||
r.GET("/battery", GetAllBatteries) | ||
r.Run(":" + Port) | ||
} | ||
|
||
func GetAllECUs(c *gin.Context) { | ||
var ecus []ECU | ||
DB.Find(&ecus) | ||
c.JSON(http.StatusOK, ecus) | ||
} | ||
|
||
func GetAllBatteries(c *gin.Context) { | ||
var batteries []Battery | ||
DB.Find(&batteries) | ||
c.JSON(http.StatusOK, batteries) | ||
} |
Oops, something went wrong.