mirror of
https://github.com/LucasVbr/LucasVbr.git
synced 2026-07-09 14:27:46 +00:00
New Version of README Profile
This commit is contained in:
@@ -3,29 +3,46 @@
|
||||
__author__ = "LucasVbr"
|
||||
__version__ = "3.0.0"
|
||||
|
||||
from flask import render_template
|
||||
import requests
|
||||
from flask import render_template
|
||||
import flask
|
||||
import json
|
||||
from Badge import *
|
||||
from FileUtils import *
|
||||
from datetime import datetime
|
||||
|
||||
TEMPLATE_FILE = "index.md.jinja"
|
||||
DATA_FILE = "data.json"
|
||||
DATA_FILE = "data.old.json"
|
||||
TOOLS_DATA = "tools.json"
|
||||
OUTPUT_FILE = "README.md"
|
||||
|
||||
app = flask.Flask('my app')
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Get Data from JSON
|
||||
with open(DATA_FILE) as file:
|
||||
data = json.load(file)
|
||||
data = getJsonData(DATA_FILE)
|
||||
|
||||
# Get random quote
|
||||
quote = requests.get("https://api.quotable.io/random")
|
||||
toolsData = getJsonData(TOOLS_DATA)
|
||||
tools = [Badge(toolName) for toolName in toolsData]
|
||||
|
||||
tools.sort(key=getBadgeColor) # Sort by color
|
||||
|
||||
request = requests.get("https://goweather.herokuapp.com/weather/rodez")
|
||||
|
||||
weather_status = request.status_code
|
||||
weather = request.json()
|
||||
|
||||
today = datetime.today().strftime("%A %d %B %y, %H:%M")
|
||||
|
||||
# Build from template and data
|
||||
with app.app_context():
|
||||
rendered = render_template(TEMPLATE_FILE, data=data, quote=quote.json())
|
||||
rendered = render_template(
|
||||
TEMPLATE_FILE,
|
||||
# data=data,
|
||||
tools=tools,
|
||||
weather_status=weather_status,
|
||||
weather=weather,
|
||||
today=today
|
||||
)
|
||||
|
||||
# Generate Markdown file
|
||||
with open(OUTPUT_FILE, "w", encoding="utf8") as file:
|
||||
file.write(rendered)
|
||||
setFileData(OUTPUT_FILE, rendered)
|
||||
|
||||
Reference in New Issue
Block a user