Compare commits
4 Commits
5166777e40
...
d81ff0592e
Author | SHA1 | Date | |
---|---|---|---|
d81ff0592e | |||
52866f9c84 | |||
d9a73a6fd9 | |||
7aa57af9ef |
4
.gitignore
vendored
4
.gitignore
vendored
@ -24,11 +24,11 @@ dist/
|
|||||||
downloads/
|
downloads/
|
||||||
eggs/
|
eggs/
|
||||||
.eggs/
|
.eggs/
|
||||||
lib/
|
#lib/
|
||||||
lib64/
|
lib64/
|
||||||
parts/
|
parts/
|
||||||
sdist/
|
sdist/
|
||||||
var/
|
#var/
|
||||||
wheels/
|
wheels/
|
||||||
pip-wheel-metadata/
|
pip-wheel-metadata/
|
||||||
share/python-wheels/
|
share/python-wheels/
|
||||||
|
2
LICENSE
2
LICENSE
@ -219,7 +219,7 @@ If you develop a new program, and you want it to be of the greatest possible use
|
|||||||
|
|
||||||
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.
|
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
flaskapp
|
taskmanager
|
||||||
Copyright (C) 2023 Decentrala
|
Copyright (C) 2023 Decentrala
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
# flaskapp
|
# taskmanager
|
||||||
|
|
||||||
Web app
|
|
||||||
|
|
||||||
|
Interactive TODO list web application
|
||||||
|
12
build-deb/taskmanager/lib/systemd/system/taskmanager.service
Normal file
12
build-deb/taskmanager/lib/systemd/system/taskmanager.service
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Gunicorn taskmanager service
|
||||||
|
Documentation=man:gunicorn(1)
|
||||||
|
After=network.target nss-lookup.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
WorkingDirectory=/var/taskmanager/
|
||||||
|
ExecStart=/usr/bin/gunicorn --workers 3 --bind 127.0.0.1:5000 run:app
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
|
@ -1,8 +1,9 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
from flaskapp import db
|
from taskmanager import db, app
|
||||||
|
|
||||||
print('[i] Trying to create databse...')
|
print('[i] Trying to create databse...')
|
||||||
try:
|
try:
|
||||||
|
with app.app_context():
|
||||||
db.create_all()
|
db.create_all()
|
||||||
print('[+] Success you can proceed with deployment!')
|
print('[+] Success you can proceed with deployment!')
|
||||||
except:
|
except:
|
||||||
|
3
run.py
3
run.py
@ -1,4 +1,5 @@
|
|||||||
from flaskapp import app
|
#!/usr/bin/env python3
|
||||||
|
from taskmanager import app
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run(debug=False)
|
app.run(debug=False)
|
||||||
|
@ -8,20 +8,48 @@ def index():
|
|||||||
tasks = Task.query.all()
|
tasks = Task.query.all()
|
||||||
return render_template('index.html', tasks = tasks)
|
return render_template('index.html', tasks = tasks)
|
||||||
|
|
||||||
@app.route('/submit', methods=['POST', 'GET'])
|
@app.route('/register', methods=['POST', 'GET'])
|
||||||
def submit():
|
def register():
|
||||||
if request.method == 'GET':
|
if request.method == 'GET':
|
||||||
return render_template('submit.html')
|
return render_template('register.html')
|
||||||
elif request.method == 'POST':
|
elif request.method == 'POST':
|
||||||
userinput1 = request.form['forminput1']
|
username = request.form['username']
|
||||||
userinput2 = request.form['forminput2']
|
contact = request.form['contact']
|
||||||
sqlrow = Table(variable1 = int(userinput1), variable2 = int(userinput2))
|
sqladduser = User(username = username, contact = contact)
|
||||||
try:
|
try:
|
||||||
db.session.add(sqlrow)
|
db.session.add(sqladduser)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
return 'Row added'
|
return 'User added'
|
||||||
except:
|
except:
|
||||||
return 'Adding row to table failed'
|
return 'Adding user failed'
|
||||||
|
|
||||||
else:
|
else:
|
||||||
return 'HTTP request method not recogniezed'
|
return 'HTTP request method not recogniezed'
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/projects/<int:task_id>', methods=['GET','POST'])
|
||||||
|
def project(task_id:int):
|
||||||
|
if request.method == 'GET':
|
||||||
|
try:
|
||||||
|
task = Task.query.get(task_id)
|
||||||
|
except:
|
||||||
|
return 'Task not found, bad URL'
|
||||||
|
try:
|
||||||
|
userid = TaskUser.query.filter_by(taskid = task_id).first().userid
|
||||||
|
users = User.query.get(userid).username
|
||||||
|
except:
|
||||||
|
users = "No users added to this task"
|
||||||
|
return render_template("project.html", task = task, users = users)
|
||||||
|
elif request.method == 'POST':
|
||||||
|
username = request.form['username']
|
||||||
|
try:
|
||||||
|
userid = User.query.filter_by(username = username).first().id
|
||||||
|
except:
|
||||||
|
return 'User not found, please <a href="/register">register</a>.'
|
||||||
|
sqladduser = TaskUser(userid = userid, taskid = task_id)
|
||||||
|
try:
|
||||||
|
db.session.add(sqladduser)
|
||||||
|
db.session.commit()
|
||||||
|
return 'User added'
|
||||||
|
except:
|
||||||
|
return 'Adding user failed'
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
<main>
|
<main>
|
||||||
<section>
|
<section>
|
||||||
{% for task in tasks %}
|
{% for task in tasks %}
|
||||||
<li>{{task}}</li>
|
<li><a href="/projects/{{task.id}}"> {{task.name}} </a></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</section>
|
</section>
|
||||||
</main>
|
</main>
|
||||||
|
29
taskmanager/templates/project.html
Normal file
29
taskmanager/templates/project.html
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Decentrala</title>
|
||||||
|
<link rel="stylesheet" href="/static/style.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header>
|
||||||
|
</header>
|
||||||
|
<main>
|
||||||
|
<section>
|
||||||
|
<li>{{task.name}}</li>
|
||||||
|
<li>{{task.desc}}</li>
|
||||||
|
<li>{{users}}</li>
|
||||||
|
</section>
|
||||||
|
<h1> Add yourself to task </h1>
|
||||||
|
<form action="/projects/{{task.id}}" method="POST">
|
||||||
|
<label for="username">username</label>
|
||||||
|
<input type="text" name="username" id="username" required>
|
||||||
|
<button> Submit </button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</main>
|
||||||
|
<footer>
|
||||||
|
</footer>
|
||||||
|
</body>
|
||||||
|
</html>
|
20
taskmanager/templates/register.html
Normal file
20
taskmanager/templates/register.html
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Register</title>
|
||||||
|
<link rel="stylesheet" href="/static/style.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<main>
|
||||||
|
<form action="/register" method="POST">
|
||||||
|
<label for="username">username</label>
|
||||||
|
<input type="text" name="username" id="username" required>
|
||||||
|
<label for="contact">contact</label>
|
||||||
|
<input type="text" name="contact" id="contact" required>
|
||||||
|
<button> Submit </button>
|
||||||
|
</form>
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -1,20 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
<title>Submit</title>
|
|
||||||
<link rel="stylesheet" href="/static/style.css">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<main>
|
|
||||||
<form action="/submit" method="POST">
|
|
||||||
<label for="forminput1">forminput1</label>
|
|
||||||
<input type="text" name="forminput1" id="forminput1" required>
|
|
||||||
<label for="forminput2">forminput2</label>
|
|
||||||
<input type="text" name="forminput2" id="forminput2" required>
|
|
||||||
<button> Submit </button>
|
|
||||||
</form>
|
|
||||||
</main>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
Loading…
Reference in New Issue
Block a user