thematdevdotorg/main.py
2020-11-06 17:51:15 +03:00

44 lines
947 B
Python

import flask
import os
import numpy.random as gaussian_rnd
app = flask.Flask(__name__, subdomain_matching=True)
app.config['SERVER_NAME'] = 'thematdev.local:22837'
def generate_iq():
return round(gaussian_rnd.normal(loc=100.0, scale=15.0, size=None))
@app.context_processor
def override_url_for():
return dict(url_for=dated_url_for)
def dated_url_for(endpoint, **values):
if endpoint == 'static':
filename = values.get('filename', None)
if filename:
file_path = os.path.join(app.root_path, endpoint, filename)
values['q'] = int(os.stat(file_path).st_mtime)
return flask.url_for(endpoint, **values)
@app.route('/')
def index():
return flask.render_template('index.html', random_number=generate_iq())
@app.route('/', subdomain='tex')
def texindex():
return "Fuck you, leatherman!"
def main():
app.run('thematdev.local', 22837)
if __name__ == '__main__':
main()