فهرست منبع

prepare to deploy

Daniel Sheffield 1 سال پیش
والد
کامیت
0dc613e5e2
1فایلهای تغییر یافته به همراه11 افزوده شده و 11 حذف شده
  1. 11 11
      app/rest/pyapi.py

+ 11 - 11
app/rest/pyapi.py

@@ -9,7 +9,7 @@ from threading import Thread
 from typing import Union
 from bottle import (
     route, request, response,
-    redirect, abort, 
+    redirect, abort,
     template, static_file,
     FormsDict, HTTPError,
 )
@@ -43,9 +43,9 @@ def trend(key: str, forms: FormsDict, cache: Cache):
     page = cache[key]
     if page:
         return page
-    
+
     _, _, path, *_ = request.urlparts
-    
+
     return cache.add(key, CachedLoadingPage(
         template("loading", progress=[]),
         lambda queue: Thread(target=worker.trend, args=(
@@ -90,10 +90,10 @@ def tags(cur: Cursor[TupleRow], key: Union[int, str], forms: FormsDict, cache: C
     return get_tags(cur, forms)
 
 CLIP_SIZE_LIMIT = 65535
-SCHEME = "http://" #"https://"
+SCHEME = "https://"
 HOST = ""
-DOMAIN = "0.0.0.0" #"shandan.one"
-PORT = 6772 #""
+DOMAIN = "shandan.one"
+PORT = ""
 LOCATION = SCHEME + (f"{HOST}." if HOST else "") + DOMAIN + (f":{PORT}" if PORT else "")
 
 @route('/clip', method=['GET', 'POST'])
@@ -122,20 +122,20 @@ def clip():
             disabled=True if content else False,
             download=f'/clip/{_hash}' if content else None
         )
-    
+
     if request.method == 'POST':
         if 'paste' not in request.params:
             return abort(400, "Missing parameter: 'paste'")
-        
+
         # TODO: what is correct overhead for form content?
         OVERHEAD = 1024
         if 'paste' not in request.query and request.content_length == -1 or request.content_length > CLIP_SIZE_LIMIT + OVERHEAD:
             return abort(418, f"Paste size can not exceed {CLIP_SIZE_LIMIT}")
-        
+
         content = request.params['paste'].encode('utf-8')
         if len(content) > CLIP_SIZE_LIMIT:
             return abort(418, f"Paste size can not exceed {CLIP_SIZE_LIMIT}")
-        
+
         _bytes = blake(content, person='clip'.encode('utf-8'))
         _b32 = bytes_to_base32(_bytes)
         directory = f'app/rest/static/{_b32}'
@@ -178,5 +178,5 @@ def get_clip(filename):
     ret = validate(filename)
     if isinstance(ret, HTTPError):
         return ret
-    
+
     return static_file('/'.join([filename,]*2) + '.file', root='app/rest/static')