Compare commits
No commits in common. "d81ff0592e4e432837ade1722e96866d97ae9819" and "5166777e406dd3b74fef2ac5848fedb04380139c" have entirely different histories.
d81ff0592e
...
5166777e40
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.
|
||||||
|
|
||||||
taskmanager
|
flaskapp
|
||||||
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,3 +1,4 @@
|
|||||||
# taskmanager
|
# flaskapp
|
||||||
|
|
||||||
|
Web app
|
||||||
|
|
||||||
Interactive TODO list web application
|
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
[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,10 +1,9 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
from taskmanager import db, app
|
from flaskapp import db
|
||||||
|
|
||||||
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:
|
||||||
print('[-] Creating db failed :/')
|
print('[-] Creating db failed :/')
|
||||||
|
3
run.py
3
run.py
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
from flaskapp import app
|
||||||
from taskmanager import app
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run(debug=False)
|
app.run(debug=False)
|
||||||
|
@ -8,48 +8,20 @@ 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('/register', methods=['POST', 'GET'])
|
@app.route('/submit', methods=['POST', 'GET'])
|
||||||
def register():
|
def submit():
|
||||||
if request.method == 'GET':
|
if request.method == 'GET':
|
||||||
return render_template('register.html')
|
return render_template('submit.html')
|
||||||
elif request.method == 'POST':
|
elif request.method == 'POST':
|
||||||
username = request.form['username']
|
userinput1 = request.form['forminput1']
|
||||||
contact = request.form['contact']
|
userinput2 = request.form['forminput2']
|
||||||
sqladduser = User(username = username, contact = contact)
|
sqlrow = Table(variable1 = int(userinput1), variable2 = int(userinput2))
|
||||||
try:
|
try:
|
||||||
db.session.add(sqladduser)
|
db.session.add(sqlrow)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
return 'User added'
|
return 'Row added'
|
||||||
except:
|
except:
|
||||||
return 'Adding user failed'
|
return 'Adding row to table 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><a href="/projects/{{task.id}}"> {{task.name}} </a></li>
|
<li>{{task}}</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</section>
|
</section>
|
||||||
</main>
|
</main>
|
||||||
|
@ -1,29 +0,0 @@
|
|||||||
<!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>
|
|
@ -1,20 +0,0 @@
|
|||||||
<!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>
|
|
20
taskmanager/templates/submit.html
Normal file
20
taskmanager/templates/submit.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>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…
x
Reference in New Issue
Block a user