Flask -> FastAPI

This commit is contained in:
DomySh
2022-06-28 13:26:06 +02:00
parent d781801bac
commit 3f2e8bb2f8
9 changed files with 307 additions and 435 deletions

View File

@@ -7,11 +7,10 @@ var Buffer = require('buffer').Buffer
export const eventUpdateName = "update-info"
const custom_url = (!process.env.NODE_ENV || process.env.NODE_ENV === 'development')?"http://127.0.0.1:8080":""
export async function getapi(path:string):Promise<any>{
return await new Promise((resolve, reject) => {
fetch(`${custom_url}/api/${path}`,{credentials: "same-origin"})
fetch(`/api/${path}`,{credentials: "same-origin"})
.then(res => {
if(res.status === 401) window.location.reload()
if(!res.ok) reject(res.statusText)
@@ -25,7 +24,7 @@ export async function getapi(path:string):Promise<any>{
export async function postapi(path:string,data:any):Promise<any>{
return await new Promise((resolve, reject) => {
fetch(`${custom_url}/api/${path}`, {
fetch(`/api/${path}`, {
method: 'POST',
credentials: "same-origin",
cache: 'no-cache',