Compare commits
No commits in common. "9973f46bc53f9d9e563473f49224723ce2807db3" and "e22941d33524b53987a36feb48d08dc12bef0806" have entirely different histories.
9973f46bc5
...
e22941d335
|
|
@ -1,20 +0,0 @@
|
||||||
# Use the official Python image from the Docker Hub
|
|
||||||
FROM python:3.9-slim
|
|
||||||
|
|
||||||
# Set the working directory in the container
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
# Copy the requirements file into the container
|
|
||||||
COPY requirements.txt .
|
|
||||||
|
|
||||||
# Install the dependencies
|
|
||||||
RUN pip install --no-cache-dir -r requirements.txt
|
|
||||||
|
|
||||||
# Copy the rest of the application code into the container
|
|
||||||
COPY . .
|
|
||||||
|
|
||||||
# Expose the port the app runs on
|
|
||||||
EXPOSE 5000
|
|
||||||
|
|
||||||
# Define the command to run the application
|
|
||||||
CMD ["python", "display-all-reports/display-reports.py"]
|
|
||||||
|
|
@ -1,115 +1,49 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python
|
||||||
import os
|
|
||||||
import textwrap
|
import textwrap
|
||||||
import requests
|
import requests
|
||||||
import datetime
|
from flask import Flask, Response, request
|
||||||
from flask import Flask, Response, request, jsonify
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
USER_TOKEN = os.getenv('USER_TOKEN')
|
|
||||||
if not USER_TOKEN:
|
USER_TOKEN = ''
|
||||||
raise EnvironmentError("USER_TOKEN environment variable is not set")
|
|
||||||
|
|
||||||
def get_uploads(user_token, page=1):
|
def get_uploads(user_token, page=1):
|
||||||
return requests.get("https://dps.report/getUploads?userToken={}&page={}&perPage={}".format(user_token, page, 100)).json()
|
return requests.get("https://dps.report/getUploads?userToken={}&page={}".format(user_token, page)).json()
|
||||||
|
|
||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
def test():
|
def fetch_and_display_my_reports():
|
||||||
page = request.args.get('page', '1')
|
if request.args.get('page', ''):
|
||||||
uploads = get_uploads(USER_TOKEN, page)
|
uploads = get_uploads(USER_TOKEN, request.args.get('page', ''))
|
||||||
|
else:
|
||||||
if request.headers.get('X-Requested-With') == 'XMLHttpRequest':
|
uploads = get_uploads(USER_TOKEN)
|
||||||
return jsonify(uploads)
|
# print(uploads)
|
||||||
|
|
||||||
upload_links_html = ""
|
upload_links_html = ""
|
||||||
for upload in sorted(uploads['uploads'], key=lambda upload: upload['encounterTime'], reverse=True):
|
for upload in uploads['uploads']:
|
||||||
encounter_time = datetime.datetime.fromtimestamp(upload['encounterTime']).strftime('%Y%m%d-%H%M%S')
|
upload_links_html += ' <a href="{url}">{url}</a><br>\n'.format(url=upload['permalink'])
|
||||||
boss_name = upload['encounter']['boss']
|
|
||||||
bosses = {26712: "Ura",
|
|
||||||
26774: "Decima",
|
|
||||||
26725: "Greer"}
|
|
||||||
if boss_name == "DPS.Report":
|
|
||||||
boss_name = bosses[upload['encounter']['bossId']]
|
|
||||||
print(upload['encounter'])
|
|
||||||
if upload['encounter']['isCm'] and not upload['encounter']['isLegendaryCm']:
|
|
||||||
boss_name = boss_name + ' CM'
|
|
||||||
if upload['encounter']['isLegendaryCm']:
|
|
||||||
boss_name = boss_name + ' LCM'
|
|
||||||
if upload['encounter']['emboldened']:
|
|
||||||
boss_name = boss_name + ' (emboldened)'
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
boss_success = upload['encounter']['success']
|
|
||||||
success = '❌'
|
|
||||||
if boss_success:
|
|
||||||
success = '✅'
|
|
||||||
upload_links_html += ' <a href="{url}">{success} {encounter_time} {boss_name}</a><br>\n'.format(url=upload['permalink'],
|
|
||||||
success=success,
|
|
||||||
encounter_time=encounter_time,
|
|
||||||
boss_name=boss_name)
|
|
||||||
|
|
||||||
older_reports = "<br>Older reports: "
|
older_reports = "<br>Older reports: "
|
||||||
for i in range(uploads['pages']):
|
if uploads['pages'] > 1:
|
||||||
if page == str(i + 1):
|
for i in range(uploads['pages']):
|
||||||
older_reports += ' <a href="?page={page_number}" style="font-size: 115%;"><b>{page_number}</b></a> '.format(page_number=i + 1)
|
if request.args.get('page', '') == str(i+1):
|
||||||
else:
|
older_reports += ' <a href="?page={page_number}"><b>{page_number}</b></a> '.format(page_number=i+1)
|
||||||
older_reports += ' <a href="?page={page_number}">{page_number}</a> '.format(page_number=i + 1)
|
else:
|
||||||
|
older_reports += ' <a href="?page={page_number}">{page_number}</a> '.format(page_number=i+1)
|
||||||
|
|
||||||
|
else:
|
||||||
|
older_reports = ""
|
||||||
response_text = textwrap.dedent('''\
|
response_text = textwrap.dedent('''\
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>lennys dps reports</title>
|
<title>lennys dps reports</title>
|
||||||
<style>
|
|
||||||
<link href="https://fonts.googleapis.com/css?family=Alegreya+Sans" rel="stylesheet">
|
|
||||||
body {{
|
|
||||||
font-family: 'Alegreya Sans', sans-serif;
|
|
||||||
line-height: 1.25;
|
|
||||||
font-size: 90%;
|
|
||||||
background-color: #333333;
|
|
||||||
}}
|
|
||||||
</style>
|
|
||||||
<script>
|
|
||||||
function loadReports(page) {{
|
|
||||||
var xhr = new XMLHttpRequest();
|
|
||||||
xhr.open('GET', '/?page=' + page, true);
|
|
||||||
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
|
|
||||||
xhr.onload = function() {{
|
|
||||||
if (xhr.status === 200) {{
|
|
||||||
var data = JSON.parse(xhr.responseText);
|
|
||||||
var uploadLinksHtml = '';
|
|
||||||
data.uploads.sort((a, b) => b.encounterTime - a.encounterTime).forEach(upload => {{
|
|
||||||
var encounterTime = new Date(upload.encounterTime * 1000).toISOString().replace('T', ' ').substring(0, 19);
|
|
||||||
var bossName = upload.encounter.boss;
|
|
||||||
if (upload.encounter.isCm) {{
|
|
||||||
bossName += ' CM';
|
|
||||||
}}
|
|
||||||
var success = upload.encounter.success ? '✅' : '❌';
|
|
||||||
uploadLinksHtml += `<a href="${{upload.permalink}}">${{success}} ${{encounterTime}} ${{bossName}}</a><br>`;
|
|
||||||
}});
|
|
||||||
document.getElementById('upload-links').innerHTML = uploadLinksHtml;
|
|
||||||
}}
|
|
||||||
}};
|
|
||||||
xhr.send();
|
|
||||||
}}
|
|
||||||
</script>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="upload-links">
|
{upload_links}{older_reports}
|
||||||
{upload_links_html}
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
{older_reports}
|
|
||||||
</div>
|
|
||||||
</body>
|
</body>
|
||||||
<footer style="font-size: 50%; font-family: 'Alegreya Sans', sans-serif;">
|
</html>'''.format(upload_links=upload_links_html, older_reports=older_reports))
|
||||||
<br><br>
|
|
||||||
made with ♥ by lenny.2437
|
|
||||||
</footer>
|
|
||||||
</html>'''.format(upload_links_html=upload_links_html, older_reports=older_reports))
|
|
||||||
return Response(response_text, mimetype='text/html')
|
return Response(response_text, mimetype='text/html')
|
||||||
|
|
||||||
if __name__ == "__main__":
|
def start():
|
||||||
app.run()
|
app = Flask(__name__)
|
||||||
|
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
Flask==2.3.2
|
|
||||||
requests==2.31.0
|
|
||||||
Loading…
Reference in New Issue
Block a user