kopia lustrzana https://github.com/simonw/datasette
				
				
				
			
							rodzic
							
								
									d9aad1fd04
								
							
						
					
					
						commit
						d8351b08ed
					
				| 
						 | 
				
			
			@ -439,6 +439,10 @@ def uninstall(packages, yes):
 | 
			
		|||
    "--token",
 | 
			
		||||
    help="API token to send with --get requests",
 | 
			
		||||
)
 | 
			
		||||
@click.option(
 | 
			
		||||
    "--actor",
 | 
			
		||||
    help="Actor to use for --get requests (JSON string)",
 | 
			
		||||
)
 | 
			
		||||
@click.option("--version-note", help="Additional note to show on /-/versions")
 | 
			
		||||
@click.option("--help-settings", is_flag=True, help="Show available settings")
 | 
			
		||||
@click.option("--pdb", is_flag=True, help="Launch debugger on any errors")
 | 
			
		||||
| 
						 | 
				
			
			@ -493,6 +497,7 @@ def serve(
 | 
			
		|||
    root,
 | 
			
		||||
    get,
 | 
			
		||||
    token,
 | 
			
		||||
    actor,
 | 
			
		||||
    version_note,
 | 
			
		||||
    help_settings,
 | 
			
		||||
    pdb,
 | 
			
		||||
| 
						 | 
				
			
			@ -612,7 +617,10 @@ def serve(
 | 
			
		|||
        headers = {}
 | 
			
		||||
        if token:
 | 
			
		||||
            headers["Authorization"] = "Bearer {}".format(token)
 | 
			
		||||
        response = client.get(get, headers=headers)
 | 
			
		||||
        cookies = {}
 | 
			
		||||
        if actor:
 | 
			
		||||
            cookies["ds_actor"] = client.actor_cookie(json.loads(actor))
 | 
			
		||||
        response = client.get(get, headers=headers, cookies=cookies)
 | 
			
		||||
        click.echo(response.text)
 | 
			
		||||
        exit_code = 0 if response.status == 200 else 1
 | 
			
		||||
        sys.exit(exit_code)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -122,6 +122,7 @@ Once started you can access it at ``http://localhost:8001``
 | 
			
		|||
      --get TEXT                      Run an HTTP GET request against this path,
 | 
			
		||||
                                      print results and exit
 | 
			
		||||
      --token TEXT                    API token to send with --get requests
 | 
			
		||||
      --actor TEXT                    Actor to use for --get requests (JSON string)
 | 
			
		||||
      --version-note TEXT             Additional note to show on /-/versions
 | 
			
		||||
      --help-settings                 Show available settings
 | 
			
		||||
      --pdb                           Launch debugger on any errors
 | 
			
		||||
| 
						 | 
				
			
			@ -148,7 +149,9 @@ The ``--get`` option to ``datasette serve`` (or just ``datasette``) specifies th
 | 
			
		|||
 | 
			
		||||
This means that all of Datasette's functionality can be accessed directly from the command-line.
 | 
			
		||||
 | 
			
		||||
For example::
 | 
			
		||||
For example:
 | 
			
		||||
 | 
			
		||||
.. code-block:: bash
 | 
			
		||||
 | 
			
		||||
    datasette --get '/-/versions.json' | jq .
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -194,7 +197,13 @@ For example::
 | 
			
		|||
 | 
			
		||||
You can use the ``--token TOKEN`` option to send an :ref:`API token <CreateTokenView>` with the simulated request.
 | 
			
		||||
 | 
			
		||||
The exit code will be 0 if the request succeeds and 1 if the request produced an HTTP status code other than 200 - e.g. a 404 or 500 error.
 | 
			
		||||
Or you can make a request as a specific actor by passing a JSON representation of that actor to ``--actor``:
 | 
			
		||||
 | 
			
		||||
.. code-block:: bash
 | 
			
		||||
 | 
			
		||||
    datasette --memory --actor '{"id": "root"}' --get '/-/actor.json'
 | 
			
		||||
 | 
			
		||||
The exit code of ``datasette --get`` will be 0 if the request succeeds and 1 if the request produced an HTTP status code other than 200 - e.g. a 404 or 500 error.
 | 
			
		||||
 | 
			
		||||
This lets you use ``datasette --get /`` to run tests against a Datasette application in a continuous integration environment such as GitHub Actions.
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -142,6 +142,7 @@ def test_metadata_yaml():
 | 
			
		|||
        secret=None,
 | 
			
		||||
        root=False,
 | 
			
		||||
        token=None,
 | 
			
		||||
        actor=None,
 | 
			
		||||
        version_note=None,
 | 
			
		||||
        get=None,
 | 
			
		||||
        help_settings=False,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Ładowanie…
	
		Reference in New Issue