last updates
This commit is contained in:
7
app.py
7
app.py
@@ -1,7 +1,7 @@
|
||||
from flask import Flask, render_template, request, send_file, jsonify
|
||||
from datetime import datetime
|
||||
from scraper import get_google_first_page
|
||||
import io, json, csv, yaml, os
|
||||
from api import get_google_first_page
|
||||
import io, json, csv, yaml, os, requests
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
@@ -10,6 +10,7 @@ app = Flask(__name__)
|
||||
|
||||
@app.route("/", methods=["GET"])
|
||||
def index():
|
||||
|
||||
return render_template("index.html", results=[])
|
||||
|
||||
@app.route("/search", methods=["POST"])
|
||||
@@ -17,6 +18,7 @@ def search():
|
||||
query = request.form.get("q", "").strip()
|
||||
if not query:
|
||||
return render_template("index.html", error="Zadejte dotaz.")
|
||||
|
||||
try:
|
||||
results = get_google_first_page(query) # list of dicts
|
||||
except Exception as e:
|
||||
@@ -32,6 +34,7 @@ def search():
|
||||
@app.route("/export", methods=["POST"])
|
||||
def export():
|
||||
data = request.get_json()
|
||||
|
||||
ext = data.get("format", "json")
|
||||
|
||||
results = data.get("results", [])
|
||||
|
||||
Reference in New Issue
Block a user