")
async def service(request, name=None):
if(name):
with open(f"{data_dir}/services.yml", "r") as services:
data = yaml.load(services)
for service in data['services']:
if service['name'].replace(' ', '').lower() == name:
tpinfo = await get_trustpilot_info(service)
template = env.get_template('service.html')
return html(template.render(service=service, tpinfo=tpinfo))
return(f"{name} does not exist")
@app.route("/generate-new-exchange", name="new-exchange", methods=['POST', 'GET'])
async def gne(request):
if(request.args):
args = request.args
yamlString = f"""
- name: {args['name'][0]}
short-description: {args['short-d'][0]}
long-description: {args['large-d'][0]}
btc: {args['btc'][0]}
xmr: {args['xmr'][0]}
cash: {args['cash'][0]}
exchange: {args['exchange'][0]}
buy: {args['buy'][0]}
custodial: {args['custodial'][0]}
registration: {args['registration'][0]}
personal-info: {args['personal-info'][0]}
p2p: {args['p2p'][0]}
may-kyc: false
open-source: {args['open-source'][0]}
comment:
kyc-check: false
refunds: false
score: 6
tor: {args['tor'][0]}
tor-url: {args['tor-url'][0]}
tos-urls:
- {args['tos'][0]}
url: {args['url'][0]}
verified: false
score-boost: 0
"""
return(html(yamlString))
template = env.get_template('generate-new-exchange.html')
if(request.json):
return text('POST request - {}'.format(request.json))
return(html(template.render()))
@app.route("/generate-new-service", name="new-service", methods=['POST', 'GET'])
async def gns(request):
if(request.args):
args = request.args
yamlString = f"""
- name: {args['name'][0]}
short-description: {args['short-d'][0]}
long-description: {args['large-d'][0]}
btc: {args['btc'][0]}
xmr: {args['xmr'][0]}
cash: {args['cash'][0]}
registration: {args['registration'][0]}
personal-info: {args['personal-info'][0]}
open-source: {args['open-source'][0]}
tor: {args['tor'][0]}
tor-url: {args['tor-url'][0]}
tos-url: {args['tos'][0]}
url: {args['url'][0]}
verified: false
"""
return(html(yamlString))
template = env.get_template('generate-new-service.html')
if(request.json):
return text('POST request - {}'.format(request.json))
return(html(template.render()))
async def get_trustpilot_info(service):
r = httpx.get(
f"https://www.trustpilot.com/review/{service['url'].replace('https://', '')[:-1]}")
soup = BeautifulSoup(r.content, features="html.parser")
if soup.find_all('div', class_="error-page"):
trustscore = False
review_count = ''
tplink = "#"
else:
trustscore = soup.find_all('p', class_='header_trustscore')[0].text
review_count = soup.find_all(
'span', class_="headline__review-count")[0].text
tplink = f"https://www.trustpilot.com/review/{service['url'].replace('https://', '')[:-1]}"
tpinfo = {
'score': trustscore,
'count': review_count,
'link': tplink
}
return tpinfo