dodati dinamicku boju, slike, te lijepsi kod
This commit is contained in:
parent
d2872a8fbf
commit
1c216985f1
8 changed files with 122 additions and 106 deletions
17
code/main.py
17
code/main.py
|
|
@ -1,8 +1,9 @@
|
|||
from flask import Flask, render_template_string
|
||||
from flask import Flask, render_template_string, send_file
|
||||
import subprocess
|
||||
import os
|
||||
import re
|
||||
import datetime
|
||||
from waitress import serve
|
||||
pocelo = datetime.datetime.now()
|
||||
app = Flask(__name__)
|
||||
visits = 0
|
||||
|
|
@ -22,7 +23,11 @@ base_dir = os.path.abspath('..')
|
|||
html_files = {
|
||||
'index.html': os.path.join(base_dir, 'html', 'index.html'),
|
||||
'projects.html': os.path.join(base_dir, 'html', 'projects.html'),
|
||||
'contribute.html': os.path.join(base_dir, 'html', 'contribute.html')
|
||||
'contribute.html': os.path.join(base_dir, 'html', 'contribute.html'),
|
||||
'foss.jpg': os.path.join(base_dir, 'html', 'foss.jpg'),
|
||||
'git.png': os.path.join(base_dir, 'html', 'git.png'),
|
||||
'main.css': os.path.join(base_dir, 'html', 'main.css'),
|
||||
'main.js': os.path.join(base_dir, 'html', 'main.js'),
|
||||
}
|
||||
|
||||
visit_file = os.path.join(base_dir, 'visits.txt')
|
||||
|
|
@ -62,10 +67,16 @@ def home():
|
|||
@app.route('/<page>')
|
||||
def other_pages(page):
|
||||
if page in html_files:
|
||||
if(not page.endswith('.html')):
|
||||
if(page.endswith('.css')):
|
||||
with open(html_files[page], 'rb') as file:
|
||||
return send_file(html_files[page], mimetype="text/css")
|
||||
with open(html_files[page], 'rb') as file:
|
||||
return file.read()
|
||||
content = replace_placeholders(html_files[page])
|
||||
return content
|
||||
else:
|
||||
return "<h1>Stranica nije pronađena</h1>", 404
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(debug=True, host='0.0.0.0', port=8000)
|
||||
serve(app,host='0.0.0.0', port=8000)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue