Skip to content

Commit

Permalink
add simple text search api
Browse files Browse the repository at this point in the history
  • Loading branch information
binjie09 committed Mar 20, 2023
1 parent 27a738f commit f36bc62
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
myenv
.idea
__pycache__
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
# duckduckgo-api
# duckduckgo-api

```bash
python3 -m venv myenv && source myenv/bin/activate && pip install -r requirements.txt

```
19 changes: 19 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from flask import Flask, request

app = Flask(__name__)


@app.route('/search')
def hello_world(): # put application's code here
from duckduckgo_search import ddg

keywords = request.args.get('q')
print(request.args.get('max_results'))
max_results = request.args.get('max_results') or 3
results = ddg(keywords, region='wt-wt', safesearch='Off', time='y', max_results=max_results)
print(results)
return results


if __name__ == '__main__':
app.run(host='0.0.0.0')
15 changes: 15 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
certifi==2022.12.7
charset-normalizer==3.1.0
click==8.1.3
duckduckgo-search==2.8.5
Flask==2.2.3
gunicorn==20.1.0
idna==3.4
importlib-metadata==6.1.0
itsdangerous==2.1.2
Jinja2==3.1.2
MarkupSafe==2.1.2
requests==2.28.2
urllib3==1.26.15
Werkzeug==2.2.3
zipp==3.15.0

0 comments on commit f36bc62

Please sign in to comment.