Uses Django now because Flask is insecure in prod
This commit is contained in:
36
main.py
36
main.py
@@ -1,34 +1,32 @@
|
||||
from flask import Flask, render_template, request, redirect
|
||||
from django.shortcuts import render
|
||||
from django.urls import path
|
||||
from django.http import HttpResponse
|
||||
import os
|
||||
from datetime import datetime
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
def decide_ascii():
|
||||
day = datetime.today().strftime('%d')
|
||||
month = datetime.today().strftime('%m')
|
||||
|
||||
if month == "12":
|
||||
return open(f'./ascii/christmas.html', 'r').read()
|
||||
return open('./ascii/christmas.html', 'r').read()
|
||||
if month == "10":
|
||||
return open(f'./ascii/halloween.html', 'r').read()
|
||||
return open('./ascii/halloween.html', 'r').read()
|
||||
else:
|
||||
return open(f'./ascii/normal.html', 'r').read()
|
||||
return open('./ascii/normal.html', 'r').read()
|
||||
|
||||
@app.route('/')
|
||||
def index():
|
||||
def index(request):
|
||||
ascii_penguin = decide_ascii()
|
||||
return render_template('index.html', ascii_penguin = ascii_penguin)
|
||||
return render(request, 'index.html', {'ascii_penguin': ascii_penguin})
|
||||
|
||||
@app.route('/mc')
|
||||
def mc():
|
||||
def mc(request):
|
||||
ascii_penguin = decide_ascii()
|
||||
return render_template('mc.html', ascii_penguin = ascii_penguin)
|
||||
return render(request, 'mc.html', {'ascii_penguin': ascii_penguin})
|
||||
|
||||
urlpatterns = [
|
||||
path('', index, name='index'),
|
||||
path('mc', mc, name='mc'),
|
||||
]
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(
|
||||
debug = True,
|
||||
host = "0.0.0.0",
|
||||
port = 8081
|
||||
)
|
||||
|
||||
# In your main file (e.g., manage.py or wsgi.py), set up the server to run.
|
||||
# Django handles the server running automatically. Configure your settings as needed.
|
||||
|
||||
Reference in New Issue
Block a user