mirror of
https://github.com/DarrenOfficial/dpaste.git
synced 2024-11-15 16:12:51 +11:00
Backwards incompatible. API calls now need to pass all arguments via POST.
This commit is contained in:
parent
d2a704c075
commit
b046d8ab87
2 changed files with 14 additions and 15 deletions
21
docs/api.rst
21
docs/api.rst
|
@ -20,13 +20,13 @@ The UTF-8 encoded string you want to paste.
|
||||||
``lexer`` (optional)
|
``lexer`` (optional)
|
||||||
~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Can also be set via GET. The lexer string key used for highlighting.
|
The lexer string key used for highlighting. See `lexer list`_ for a full list
|
||||||
See `lexer list`_ for a full list of choices. Default: ``python``.
|
of choices. Default: ``python``.
|
||||||
|
|
||||||
``format`` (optional)
|
``format`` (optional)
|
||||||
~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Can also be set via GET. The format of the API response. Choices are:
|
The format of the API response. Choices are:
|
||||||
|
|
||||||
* ``default`` — Returns a full qualified URL wrapped in quotes. Example::
|
* ``default`` — Returns a full qualified URL wrapped in quotes. Example::
|
||||||
|
|
||||||
|
@ -51,10 +51,10 @@ Can also be set via GET. The format of the API response. Choices are:
|
||||||
``expires`` (optional)
|
``expires`` (optional)
|
||||||
~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Can also be set via GET. A keyword to indicate the lifetime of a
|
A keyword to indicate the lifetime of a snippetn in seconds. The values are
|
||||||
snippetn in seconds. The values are predefined by the server. Calling this with
|
predefined by the server. Calling this with an invalid value returns a HTTP 400
|
||||||
an invalid value returns a HTTP 400 BadRequest together with a list of valid
|
BadRequest together with a list of valid values. Default: ``2592000``. In the
|
||||||
values. Default: ``2592000``. In the default configuration valid values are:
|
default configuration valid values are:
|
||||||
|
|
||||||
* onetime
|
* onetime
|
||||||
* never
|
* never
|
||||||
|
@ -65,10 +65,9 @@ values. Default: ``2592000``. In the default configuration valid values are:
|
||||||
``filename`` (optional)
|
``filename`` (optional)
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Can also be set via GET. A filename which we use to determine a lexer, if
|
A filename which we use to determine a lexer, if ``lexer`` is not set. In case
|
||||||
``lexer`` is not set. In case we can't determine a file, the lexer will fallback
|
we can't determine a file, the lexer will fallback to ``plain`` code (no
|
||||||
to ``plain`` code (no highlighting). A given ``lexer`` will overwrite any
|
highlighting). A given ``lexer`` will overwrite any filename! Example::
|
||||||
filename! Example::
|
|
||||||
|
|
||||||
{
|
{
|
||||||
"url": "https://dpaste.de/xsWd",
|
"url": "https://dpaste.de/xsWd",
|
||||||
|
|
|
@ -296,10 +296,10 @@ FORMAT_MAPPING = {
|
||||||
@csrf_exempt
|
@csrf_exempt
|
||||||
def snippet_api(request):
|
def snippet_api(request):
|
||||||
content = request.POST.get('content', '').strip()
|
content = request.POST.get('content', '').strip()
|
||||||
lexer = request.REQUEST.get('lexer', LEXER_DEFAULT).strip()
|
lexer = request.POST.get('lexer', LEXER_DEFAULT).strip()
|
||||||
filename = request.REQUEST.get('filename', '').strip()
|
filename = request.POST.get('filename', '').strip()
|
||||||
expires = request.REQUEST.get('expires', '').strip()
|
expires = request.POST.get('expires', '').strip()
|
||||||
format = request.REQUEST.get('format', 'default').strip()
|
format = request.POST.get('format', 'default').strip()
|
||||||
|
|
||||||
if not content:
|
if not content:
|
||||||
return HttpResponseBadRequest('No content given')
|
return HttpResponseBadRequest('No content given')
|
||||||
|
|
Loading…
Reference in a new issue