first code
This commit is contained in:
parent
62f79e3156
commit
3df4c70387
5 changed files with 80 additions and 0 deletions
24
app/app.py
24
app/app.py
|
@ -0,0 +1,24 @@
|
||||||
|
from flask import *
|
||||||
|
from os import path, walk
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
@app.route('/')
|
||||||
|
def home():
|
||||||
|
return render_template('index.j2', instanceName="nyxask.nixos.internal")
|
||||||
|
|
||||||
|
@app.route('/auth/login/')
|
||||||
|
def login():
|
||||||
|
return render_template('login.j2', instanceName="nyxask.nixos.internal")
|
||||||
|
|
||||||
|
extra_dirs = ['app/templates',]
|
||||||
|
extra_files = extra_dirs[:]
|
||||||
|
for extra_dir in extra_dirs:
|
||||||
|
for dirname, dirs, files in walk(extra_dir):
|
||||||
|
for filename in files:
|
||||||
|
filename = path.join(dirname, filename)
|
||||||
|
if path.isfile(filename):
|
||||||
|
extra_files.append(filename)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
app.run(debug=True, extra_files=extra_files)
|
7
app/templates/header.j2
Normal file
7
app/templates/header.j2
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
{% macro header_home() %}
|
||||||
|
<div align="left"><a href="/">Home</a></div> <div align="right"><a href="/auth/login/">Login</a> <a href="/auth/register/">Register</a></div>
|
||||||
|
{% endmacro %}
|
||||||
|
|
||||||
|
{% macro header_login() %}
|
||||||
|
<div align="left"><a href="/">Home</a></div> <div align="right"><a href="/auth/login/">Login</a></div>
|
||||||
|
{% endmacro %}
|
22
app/templates/index.j2
Normal file
22
app/templates/index.j2
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
{% from 'header.j2' import header_home %}
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
{{ header_home() }}
|
||||||
|
<div style="text-align:center">
|
||||||
|
<h1>
|
||||||
|
Hi from {{ instanceName }}'s Nyxask!
|
||||||
|
</h1>
|
||||||
|
<label for="name">Name (optional):</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
id="name"
|
||||||
|
name="name"
|
||||||
|
size="10" />
|
||||||
|
<br>
|
||||||
|
<label for="question">Question:</label>
|
||||||
|
<textarea id="question" name="question"></textarea>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
26
app/templates/login.j2
Normal file
26
app/templates/login.j2
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
{% from 'header.j2' import header_login %}
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
{{ header_login() }}
|
||||||
|
<div style="text-align:center">
|
||||||
|
<h1>
|
||||||
|
Login to {{ instanceName }}'s Nyxask!
|
||||||
|
</h1>
|
||||||
|
<label for="name">Username: </label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
id="name"
|
||||||
|
name="name"
|
||||||
|
size="10" />
|
||||||
|
<br>
|
||||||
|
<label for="question">Password: </label>
|
||||||
|
<input
|
||||||
|
type="password"
|
||||||
|
id="password"
|
||||||
|
name="password"
|
||||||
|
size="10" />
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1 @@
|
||||||
|
flask
|
Loading…
Add table
Reference in a new issue