commit
95761b9de5
7 changed files with 87 additions and 33 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -10,3 +10,5 @@
|
||||||
.DS_Store
|
.DS_Store
|
||||||
.coverage
|
.coverage
|
||||||
/*.md
|
/*.md
|
||||||
|
/.eggs/
|
||||||
|
/devel/
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
recursive-include src/httpaste/schema *.json
|
|
||||||
recursive-incude src/httpaste/backend *.sql
|
|
||||||
73
docs/guide/getting-started.rst
Normal file
73
docs/guide/getting-started.rst
Normal file
|
|
@ -0,0 +1,73 @@
|
||||||
|
Getting Started
|
||||||
|
===============
|
||||||
|
|
||||||
|
Install
|
||||||
|
"""""""
|
||||||
|
|
||||||
|
.. code-block:: shell
|
||||||
|
|
||||||
|
$ python3 -m pip install httpaste-victorykit
|
||||||
|
$ httpaste --help
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
httpaste is publicly available at `https://httpaste.it`_, and can be accessed
|
||||||
|
over the TOR network via `https://pastefao6mwyafs3cznoe2u2a6iizw5laulrznla3dytcnvaizte73yd.onion`_ aswell. Both are hosted on different servers of different service providers.
|
||||||
|
|
||||||
|
Create Configuration
|
||||||
|
""""""""""""""""""""
|
||||||
|
|
||||||
|
.. code-block:: shell
|
||||||
|
|
||||||
|
$ httpaste default-config --dump myconfig.ini
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
The default configuration creates an in-memory SQLite backend, which is not
|
||||||
|
suitable for WWW deployments. Visit `backend`, for more
|
||||||
|
information on configuring the backend.
|
||||||
|
|
||||||
|
|
||||||
|
Run a Local Evaluation Server
|
||||||
|
"""""""""""""""""""""""""""""
|
||||||
|
|
||||||
|
.. code-block:: shell
|
||||||
|
|
||||||
|
$ httpaste standalone --config myconfig.ini --port 8080
|
||||||
|
|
||||||
|
|
||||||
|
Publish a Private Paste
|
||||||
|
"""""""""""""""""""""""
|
||||||
|
|
||||||
|
.. code-block:: shell
|
||||||
|
|
||||||
|
$ echo 'My first private paste' | curl -F 'data=<-' -u myusername:mypassword http://localhost:8080/paste/private
|
||||||
|
http://localhost:8080/paste/private/UALUA9
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
If the user does not exist, they will be created upon authentication.
|
||||||
|
|
||||||
|
|
||||||
|
Retrieve a Private Paste
|
||||||
|
""""""""""""""""""""""""
|
||||||
|
|
||||||
|
.. code-block:: shell
|
||||||
|
|
||||||
|
$ curl -u myusername:mypassword http://localhost:8080/paste/private/UALUA9
|
||||||
|
My first private paste
|
||||||
|
|
||||||
|
|
||||||
|
Publish a Public Paste
|
||||||
|
""""""""""""""""""""""
|
||||||
|
|
||||||
|
.. code-block:: shell
|
||||||
|
|
||||||
|
$ echo 'My first public paste' | curl -F 'data=<-' http://localhost:8080/paste/public
|
||||||
|
http://localhost:8080/paste/public/X4L39J
|
||||||
|
|
||||||
|
|
||||||
|
Retrieve a Public Paste
|
||||||
|
""""""""""""""""""""""""
|
||||||
|
|
||||||
|
.. code-block:: shell
|
||||||
|
|
||||||
|
$ curl http://localhost:8080/paste/public/X4L39J
|
||||||
|
My first public paste
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
[build-system]
|
[build-system]
|
||||||
requires = [
|
requires = [
|
||||||
"setuptools",
|
"setuptools",
|
||||||
"wheel"
|
"wheel",
|
||||||
|
"setuptools-scm[toml]"
|
||||||
]
|
]
|
||||||
build-backend = "setuptools.build_meta"
|
build-backend = "setuptools.build_meta"
|
||||||
|
|
||||||
|
|
@ -10,3 +11,5 @@ max_line_length = 80
|
||||||
aggressive = 3
|
aggressive = 3
|
||||||
recursive = true
|
recursive = true
|
||||||
in-place = true
|
in-place = true
|
||||||
|
|
||||||
|
[tool.setuptools_scm]
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
[metadata]
|
[metadata]
|
||||||
name = httpaste-victorykit
|
name = httpaste-victorykit
|
||||||
version = 1.0.9-alpha
|
|
||||||
author = Tiara Rodney
|
author = Tiara Rodney
|
||||||
author_email = t.rodney@victoryk.it
|
author_email = t.rodney@victoryk.it
|
||||||
description = a versatile HTTP pastebin
|
description = a versatile HTTP pastebin
|
||||||
|
|
@ -38,3 +37,7 @@ console_scripts =
|
||||||
[options.packages.find]
|
[options.packages.find]
|
||||||
where = src
|
where = src
|
||||||
|
|
||||||
|
[options.package_data]
|
||||||
|
* =
|
||||||
|
*.json
|
||||||
|
*.sql
|
||||||
|
|
@ -144,6 +144,7 @@ from configparser import ConfigParser
|
||||||
from ast import literal_eval
|
from ast import literal_eval
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
from os import environ
|
from os import environ
|
||||||
|
from importlib.resources import path as resource_path
|
||||||
|
|
||||||
from connexion import FlaskApp
|
from connexion import FlaskApp
|
||||||
from connexion.resolver import RestyResolver
|
from connexion.resolver import RestyResolver
|
||||||
|
|
@ -302,7 +303,7 @@ def get_flask_app(
|
||||||
options = {"swagger_ui": server_config.swagger_ui}
|
options = {"swagger_ui": server_config.swagger_ui}
|
||||||
|
|
||||||
#context manager returns a pathlib.Path object
|
#context manager returns a pathlib.Path object
|
||||||
with tmp_pkg_resource_text_path('httpaste.schema', 'httpaste.openapi.json') as path:
|
with resource_path('httpaste.schema', 'httpaste.openapi.json') as path:
|
||||||
|
|
||||||
application = FlaskApp(__name__, specification_dir=path.parent)
|
application = FlaskApp(__name__, specification_dir=path.parent)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
from random import choice
|
from random import choice
|
||||||
from base64 import b64decode
|
from base64 import b64decode
|
||||||
from urllib.parse import urljoin
|
from urllib.parse import urljoin
|
||||||
from importlib.resources import read_text
|
|
||||||
from tempfile import mkdtemp
|
from tempfile import mkdtemp
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
|
|
@ -35,28 +34,3 @@ def decode(data: str, encoding: str) -> bytes:
|
||||||
def join_url(base:str, url: str) -> str:
|
def join_url(base:str, url: str) -> str:
|
||||||
|
|
||||||
return urljoin(base, url, True)
|
return urljoin(base, url, True)
|
||||||
|
|
||||||
|
|
||||||
@contextmanager
|
|
||||||
def tmp_pkg_resource_text_path(package:str, resource:str) -> Path:
|
|
||||||
"""context manager for accessing package resources from a real path
|
|
||||||
|
|
||||||
this applies to the circumstance of the package living inside of an
|
|
||||||
egg and therefore is unable to provide real existing paths to any
|
|
||||||
module that may require it.
|
|
||||||
|
|
||||||
:param package: dot seperated package name
|
|
||||||
:param resource: basename of resource inside package
|
|
||||||
|
|
||||||
:returns: a Path-like object
|
|
||||||
"""
|
|
||||||
data = read_text(package, resource)
|
|
||||||
tmp_dirname = mkdtemp()
|
|
||||||
tmp_dirpath = Path(tmp_dirname)
|
|
||||||
tmp_file = tmp_dirpath.joinpath(resource)
|
|
||||||
tmp_file.write_text(data)
|
|
||||||
try:
|
|
||||||
yield tmp_file
|
|
||||||
finally:
|
|
||||||
tmp_file.unlink()
|
|
||||||
tmp_dirpath.rmdir()
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue