diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0c194a2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +myenv +.idea +__pycache__ \ No newline at end of file diff --git a/README.md b/README.md index 14558ed..1fe9f87 100644 --- a/README.md +++ b/README.md @@ -1 +1,6 @@ -# duckduckgo-api \ No newline at end of file +# duckduckgo-api + +```bash +python3 -m venv myenv && source myenv/bin/activate && pip install -r requirements.txt + +``` \ No newline at end of file diff --git a/app.py b/app.py new file mode 100644 index 0000000..10921c0 --- /dev/null +++ b/app.py @@ -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') diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..9236ca7 --- /dev/null +++ b/requirements.txt @@ -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