fredag 22 juli 2022
From a list, count how many numbers are within the standard deviation from the mean. (Python)
måndag 11 juli 2022
OpenArtViewer
I've made an art viewer program in Unity. I'm now working on database update automatization in Python. That is because the files with art information provided are updated frequently.
OpenArtViewer uses the National Gallery of Art Open Data API and data from Metropolitan Museum of Art. The included SQLite database has stored info about the artworks in public domain (100K+) including image links to the artworks on the NGA and MM servers.
From the GUI you can search type of art and by title, year, artist. To the left there's a scroll bar with the results as thumbnails. These can be clicked to get more information and a higher resolution version of the artwork in the big panel to the right. A high resolution image can then be downloaded.
Download this program (Windows) https://wartem.se/files/OpenArtViewer.zip
lördag 9 juli 2022
Flask - Absolute basic client input and render
<html lang="en">
<head>
<title>Flask Basic Example</title>
</head>
<body>
<h1>Flask Post: {{ text_to_show }}</h1>
<form action="/" method="POST">
<input type="text" name="content" />
<input type="submit" />
</form>
</body></html>
app.py
from flask import Flask, render_template, request
app = Flask(__name__)
@app.route("/", methods=['GET', 'POST'])
def index():
if request.method == 'POST':
user_input = request.form['content']
return render_template("index.html", text_to_show=user_input)
return render_template("index.html")
if __name__ == "__main__":
app.run(debug=True, port=5000)
How it's used: Run app.py and go to http://127.0.0.1:5000 in your browser. Type some input, press send and the server will update the HTML with your input in a HTML paragraph. The Internet is full of extensive guides and tutorials. Sometimes you just want a quick example.
Python Virtual Environment Setup
py -m pip install --user virtualenv
Run in project folder:
py -m venv env
Run in project folder:
.\env\Scripts\activate
Done! Happy coding.