This repository has been archived on 2023-10-01. You can view files and clone it, but cannot push or open issues or pull requests.
PyNyaaTa/app.py

57 lines
1.2 KiB
Python
Raw Normal View History

2019-11-25 21:52:22 +00:00
from os import environ
2019-11-30 15:52:13 +00:00
from flask import redirect, render_template, url_for, request
2019-11-25 21:52:22 +00:00
2019-11-29 14:04:32 +00:00
from config import app, auth
2019-11-30 15:52:13 +00:00
from connectors import *
2019-11-29 14:04:32 +00:00
from models import SearchForm
2019-11-25 21:52:22 +00:00
2019-11-28 21:20:22 +00:00
@auth.verify_password
def verify_password(username, password):
admin_username = environ.get('ADMIN_USERNAME', 'admin')
admin_password = environ.get('ADMIN_USERNAME', 'secret')
return username is admin_username and password is admin_password
2019-11-25 21:52:22 +00:00
@app.route('/')
2019-11-29 14:04:32 +00:00
def home():
2019-11-30 15:52:13 +00:00
return render_template('home.html', form=SearchForm())
2019-11-29 14:04:32 +00:00
@app.route('/search')
def search():
2019-11-30 15:52:13 +00:00
query = request.args.get('q')
if not query:
return redirect(url_for('home'))
results = [
Nyaa(query).run(),
Pantsu(query).run(),
YggTorrent(query, category=2179).run(),
YggTorrent(query, category=2178).run(),
AnimeUltime(query).run(),
]
return render_template('search.html', form=SearchForm(), connectors=results)
@app.route('/latest')
def latest():
return 'Hello!'
@app.route('/list')
def list_animes():
return 'Hello!'
@app.route('/admin')
@auth.login_required
def admin():
2019-11-29 14:04:32 +00:00
return 'Hello!'
2019-11-28 21:20:22 +00:00
if __name__ == '__main__':
app_debug = environ.get('FLASK_ENV', 'production') is 'development'
app.run('0.0.0.0', debug=app_debug)