<filename>Redirect websites/start.py
# -*- coding : utf-8 -*-
# @Time      : 2022-01-05 0:06
# @Author    : Zong
# @File      : start.py
# @Software  : PyCharm
# @Function  : 网页重定向
# @ChangeLog :

import flask

app = flask.Flask(__name__)


# main
@app.route('/')
def begin():
    return flask.render_template('index.html')


@app.route('/search', methods=["GET", "POST"])
def search():
    if flask.request.method == "GET":
        content = flask.request.values.get("search_text")

        content_http = content.split("/")
        if len(content_http) > 1:
            if content_http[0] != "https:":
                return flask.redirect("https://" + content)

        else:
            domain = ["com", "cn", "net"]
            content_com = content.split(".")
            content_start = content_com[0]
            content_end = content_com[len(content_com) - 1]
            if (content_start == "www" or content_end in domain):
                return flask.redirect("https://" + content)

            else:
                content_spl = content.split(" ")
                content_re = content_spl[0]
                for i in range(1, len(content_spl)):
                    print(i)
                    content_re = content_re + "+" + content_spl[i]
                    print(content_re)

                return flask.redirect(
                    "https://www4.bing.com/search?q={}&search=&form=QBLH&sp=-1&pq=sqlalchemy+%E5%92%8Csqlist3&sc=0-19&qs=n&sk=&cvid=6A404C398F2542F885DE7AA3B04E761A&pglt=675".format(
                        content_re))


app.run(debug=True)

<filename>Redirect websites/start.py
# -*- coding : utf-8 -*-
# @Time      : 2022-01-05 0:06
# @Author    : Zong
# @File      : start.py
# @Software  : PyCharm
# @Function  : 网页重定向
# @ChangeLog :

import flask

app = flask.Flask(__name__)


# main
@app.route('/')
def begin():
    return flask.render_template('index.html')


@app.route('/search', methods=["GET", "POST"])
def search():
    if flask.request.method == "GET":
        content = flask.request.values.get("search_text")

        content_http = content.split("/")
        if len(content_http) > 1:
            if content_http[0] != "https:":
                return flask.redirect("https://" + content)

        else:
            domain = ["com", "cn", "net"]
            content_com = content.split(".")
            content_start = content_com[0]
            content_end = content_com[len(content_com) - 1]
            if (content_start == "www" or content_end in domain):
                return flask.redirect("https://" + content)

            else:
                content_spl = content.split(" ")
                content_re = content_spl[0]
                for i in range(1, len(content_spl)):
                    print(i)
                    content_re = content_re + "+" + content_spl[i]
                    print(content_re)

                return flask.redirect(
                    "https://www4.bing.com/search?q={}&search=&form=QBLH&sp=-1&pq=sqlalchemy+%E5%92%8Csqlist3&sc=0-19&qs=n&sk=&cvid=6A404C398F2542F885DE7AA3B04E761A&pglt=675".format(
                        content_re))


app.run(debug=True)

# -*- coding : utf-8 -*- # @Time      : 2022-01-05 0:06 # @Author    : Zong # @File      : start.py # @Software  : PyCharm # @Function  : 网页重定向 # @ChangeLog : # main