Clean up some unnecessary code

Signed-off-by: Skylar "The Cobra" Widulski <cobra@vern.cc>
This commit is contained in:
Skylar "The Cobra" Widulski 2023-08-21 15:30:38 -04:00
parent cdb9c3ecd5
commit b7ab6f9b74
Signed by: cobra
GPG Key ID: 4FD8F812083FF6F9
1 changed files with 1 additions and 5 deletions

View File

@ -32,9 +32,6 @@ def scrape(url):
pages = ""
return (ret, pages)
def render(data):
return render_template('index.html', data=data)
app = Flask(__name__, template_folder="templates", static_folder="static")
@app.route('/', defaults={'path': ''})
@ -43,8 +40,7 @@ def catch_all(path):
scraped = scrape(f"https://urbandictionary.com/{re.sub(r'.*://.*/', '/', request.url)}")
if type(scraped) == str and scraped.startswith("REDIRECT"):
return redirect(scraped.replace("REDIRECT ", ""), 302)
scraped = (scraped[0], str(scraped[1]).replace("»", "»").replace("›", "").replace("«", "«").replace("‹", ""))
return render(scraped)
return render_template('index.html', data=scraped)
if __name__ == '__main__':
app.run(port=8000)