Skip to content

Instantly share code, notes, and snippets.

@kasperis7
Last active January 18, 2022 07:23
Show Gist options
  • Save kasperis7/3b068ef0f9e98c8c2013bffe075e2ce9 to your computer and use it in GitHub Desktop.
Save kasperis7/3b068ef0f9e98c8c2013bffe075e2ce9 to your computer and use it in GitHub Desktop.
adnmb-search.ml
from flask import Flask
from flask import request, redirect
app = Flask(__name__)
@app.route('/', methods=["GET"])
def query_form():
return '''
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>A岛搜索 0.0.1.2</title>
</head>
<style>
@media (prefers-color-scheme: dark){
body {color:#fff;background:#000}
a:link {color:#9cf}
a:hover, a:visited:hover {color:#cef}
a:visited {color:#c9f}
}
body{
margin:1em auto;
max-width:40em;
padding:0 .62em;
font:1.2em/1.62 sans-serif;
}
h1,h2,h3 {
line-height:1.2;
}
@media print{
body{
max-width:none
}
}
footer {
font:0.8em sans-serif;
font-style:italic;
}
</style>
<body>
<header>
<h3 align="center">A岛搜索 0.0.1.2</h3>
</header>
<main>
<div align="center">
<img src="http://cover.acfunwiki.org/cover.php" title="阿苇"/>
<form action="/" method="post">
<input name="query">
<button type="submit">搜索</button>
<p></p>
</form>
</div>
</main>
<footer>
<p align="center">搜索结果由必应提供。
<a href="https://gist.github.com/kasperis7/3b068ef0f9e98c8c2013bffe075e2ce9">源码</a></p>
</footer>
</body>
</html>
'''
@app.route('/', methods=["POST"])
def result():
query = request.form['query']
args = 'site:adnmb3.com'
if (query.find(args)==-1):
query = query + ' ' + args
return redirect("https://cn.bing.com/search?q=" + query, code=301)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment