Search using special commands
Project description
Bounce
It's a keyword search engine, meaning you can configure it to redirect yt to Youtube, so a search like yt weird al would redirect right to Youtube's search.
1 minute getting started
-
Install it
$ pip install bounce -
Start it:
$ bounce serve --host "127.0.0.1:5000" -
Query it:
$ curl "http://127.0.0.1:5000/?q=yt weird al"
You can also run it using any WSGI server like uWSGI using the included bouncefile.py as the wsgi-file.
Configuration
url configuration
Bounce has a built-in configuration file with generic mappings but you can also create your own that bounce will read when starting by setting the environment variable BOUNCE_CONFIG with a path to your custom configuration python file:
export BOUNCE_CONFIG=/path/to/bounce_config.py
The file must import bounce.config.commands:
from bounce.config import commands
The commands.add() method takes a space separated list of commands and a value:
commands.add("foo bar", "http://foo.com?q={}")
So, if you called bounce with the input:
foo blammo
It would redirect to:
http://foo.com?q=blammo
You could also call it with bar blammo and get the same thing because we set up the command keywords as foo bar so either foo or bar would redirect.
Notice that the value is a python format string.
callback configuration
value can also be a callback:
def callback(q):
# manipulat q in some way and then return where you would like to go
return 'http://some.url.that.needed.manipulation.q.com={}'.format(q)
commands.add("foo bar", callback)
That makes it so bounce can do all kinds of crazy things.
default configuration
By default, Google is the search engine of choice, so if you don't start your request with a command, bounce will redirect to Google search with your search string. If you would like to change this just pass default=True to one of your custom commands:
commands.add("keyword", "value", default=True)
Viewing configuration
the command ls will list all the commands bounce supports
Testing
To test locally from the repo:
$ export BOUNCE_CONFIG=/path/to/bounce/config.py
$ python -m bounce serve --host "127.0.0.1:5000"
That should produce output that ends with the bound hostname and port:
...
Server is listening on 127.0.0.1:5000
Which you can then use to test:
$ curl "http://127.0.0.1:5000/?q=..."
And that's it.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bounce-0.7.0.tar.gz.
File metadata
- Download URL: bounce-0.7.0.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b6015fae399b93921fa58df54bc5af736d55336d3c90819b03da38fc45fefdc
|
|
| MD5 |
c8e2e73269b0b4d86dcfc54184b8070c
|
|
| BLAKE2b-256 |
1f05f9b61757fcaf55bc7d9b693bcc771ad40a53c91545df3f431d9215427506
|
File details
Details for the file bounce-0.7.0-py3-none-any.whl.
File metadata
- Download URL: bounce-0.7.0-py3-none-any.whl
- Upload date:
- Size: 10.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ab0334633212e7b61030e9c62c80b5984f94a1ff75c5fe036bd07e9b874f8c0
|
|
| MD5 |
667d281ee056644f4619a8a576fbb35f
|
|
| BLAKE2b-256 |
336871cf6bef65d3603927ad5e5cceb7caeceda8583f53e0c354886ae487acd6
|