forked from cobra/rural-dict
Clean up some unnecessary code
Signed-off-by: Skylar "The Cobra" Widulski <cobra@vern.cc>
This commit is contained in:
parent
cdb9c3ecd5
commit
b7ab6f9b74
6
main.py
6
main.py
|
@ -32,9 +32,6 @@ def scrape(url):
|
||||||
pages = ""
|
pages = ""
|
||||||
return (ret, pages)
|
return (ret, pages)
|
||||||
|
|
||||||
def render(data):
|
|
||||||
return render_template('index.html', data=data)
|
|
||||||
|
|
||||||
app = Flask(__name__, template_folder="templates", static_folder="static")
|
app = Flask(__name__, template_folder="templates", static_folder="static")
|
||||||
|
|
||||||
@app.route('/', defaults={'path': ''})
|
@app.route('/', defaults={'path': ''})
|
||||||
|
@ -43,8 +40,7 @@ def catch_all(path):
|
||||||
scraped = scrape(f"https://urbandictionary.com/{re.sub(r'.*://.*/', '/', request.url)}")
|
scraped = scrape(f"https://urbandictionary.com/{re.sub(r'.*://.*/', '/', request.url)}")
|
||||||
if type(scraped) == str and scraped.startswith("REDIRECT"):
|
if type(scraped) == str and scraped.startswith("REDIRECT"):
|
||||||
return redirect(scraped.replace("REDIRECT ", ""), 302)
|
return redirect(scraped.replace("REDIRECT ", ""), 302)
|
||||||
scraped = (scraped[0], str(scraped[1]).replace("»", "»").replace("âº", "›").replace("«", "«").replace("â¹", "‹"))
|
return render_template('index.html', data=scraped)
|
||||||
return render(scraped)
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run(port=8000)
|
app.run(port=8000)
|
||||||
|
|
Loading…
Reference in New Issue