mirror of
https://github.com/DarrenOfficial/dpaste.git
synced 2024-12-23 15:13:06 +11:00
API call accepts the lexer or format parameters now via GET too.
With this you can set the format by the url: /api/?format=json
This commit is contained in:
parent
d3e497df4c
commit
dbfbcf54b6
3 changed files with 9 additions and 6 deletions
|
@ -4,6 +4,8 @@ Changelog
|
|||
2.4 (dev)
|
||||
----------------
|
||||
|
||||
* API accepts the format or lexer via GET too. You can call an API url like
|
||||
``example.com/api/?format=json`` and have the body in POST only.
|
||||
* Added an option to keep snippets forever
|
||||
|
||||
2.3 (2014-01-07)
|
||||
|
|
|
@ -20,13 +20,13 @@ Required. The UTF-8 encoded string you want to paste.
|
|||
``lexer`` (optional)
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Optional. The lexer string key used for highlighting. See `lexer list`_ for
|
||||
a full list of choices. Default: ``python``.
|
||||
Optional. Can also be set via GET. The lexer string key used for highlighting.
|
||||
See `lexer list`_ for a full list of choices. Default: ``python``.
|
||||
|
||||
``format`` (optional)
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Optional. The format of the API response. Choices are:
|
||||
Optional. Can also be set via GET. The format of the API response. Choices are:
|
||||
|
||||
* ``default`` — Returns a full qualified URL wrapped in quotes. Example::
|
||||
|
||||
|
@ -80,5 +80,6 @@ A sample Python 2 script to publish snippets::
|
|||
|
||||
You can simply use curl to publish a whole file::
|
||||
|
||||
$ alias dpaste="curl -F 'content=<-' https://dpaste.de/api/"
|
||||
$ alias dpaste="curl -F 'content=<-' https://dpaste.de/api/?format=url"
|
||||
$ cat foo.txt | dpaste
|
||||
https://dpaste.de/ke2pB
|
||||
|
|
|
@ -269,8 +269,8 @@ FORMAT_MAPPING = {
|
|||
@csrf_exempt
|
||||
def snippet_api(request):
|
||||
content = request.POST.get('content', '').strip()
|
||||
lexer = request.POST.get('lexer', LEXER_DEFAULT).strip()
|
||||
format = request.POST.get('format', 'default').strip()
|
||||
lexer = request.REQUEST.get('lexer', LEXER_DEFAULT).strip()
|
||||
format = request.REQUEST.get('format', 'default').strip()
|
||||
|
||||
if not content:
|
||||
return HttpResponseBadRequest('No content given')
|
||||
|
|
Loading…
Reference in a new issue