/etc/systemd/system/pyfilebrowser.service
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
import logging | |
from http import HTTPStatus | |
import httpx | |
import uvicorn.logging | |
from fastapi import FastAPI, HTTPException, Request, Response | |
from fastapi.routing import APIRoute | |
TARGET_URL = "http://127.0.0.1:8080" # Change this to the URL you want to proxy requests to | |
CLIENT = httpx.Client() |
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
import logging | |
from http import HTTPStatus | |
import httpx | |
import uvicorn.logging | |
from fastapi import FastAPI, HTTPException, Request, Response | |
from fastapi.routing import APIRoute | |
TARGET_URL = "http://127.0.0.1:8080" # Change this to the URL you want to proxy requests to |
Preferred File Location
/var/www/html
Assign www-data
as owner
sudo chown www-data:www-data /var/www/html/error.html
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
import math | |
import os | |
import time | |
from threading import Thread | |
from typing import Union | |
import inflect | |
import requests | |
import tqdm |
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
import functools | |
import time | |
def timed_cache(max_age, maxsize=128, typed=False): | |
"""Least-recently-used cache decorator with time-based cache invalidation. | |
See Also: | |
- ``lru_cache`` takes all params of the function and creates a key | |
- If even one key is changed, it will map to new entry thus refreshed. |
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
import os | |
import shutil | |
import subprocess | |
import time | |
with open('requirements.txt') as file: | |
requirements = file.readlines() | |
tmp_name = f'requirements_{int(time.time())}.txt' | |
os.rename('requirements.txt', tmp_name) |
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
import logging | |
import math | |
import pyaudio | |
_logger = logging.getLogger(__name__) | |
_logger.addHandler(logging.StreamHandler()) | |
_logger.setLevel(logging.DEBUG) | |
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
import mimetypes | |
import os | |
import wave | |
from threading import Thread | |
from typing import NoReturn, Union | |
import pyaudio | |
class PlayAudio(Thread): |
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
import os | |
from typing import List | |
import requests | |
SESSION = requests.Session() | |
headers = { | |
'Accept': 'application/vnd.github+json', | |
'Authorization': f"Bearer {os.getenv('GIT_TOKEN')}", |
NewerOlder