PrabhakarVenkat commited on
Commit
d13ab9e
·
verified ·
1 Parent(s): ba88686

Upload 14 files

Browse files
.github/ISSUE_TEMPLATE.md ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ Thanks for checking out my Flask tutorial repo! Since this is a tutorial repository, it's not updated unless a major breaking issue is discovered.
2
+ Because of the reason mentioned, please follow the checklist below when opening an issue.
3
+
4
+ Make sure to add **all the information needed to understand the problem** so that I can help. If the info is missing I'll add the 'Needs more information' label and close the issue until there is enough information.
5
+
6
+ - [ ] Provide a **minimal code snippet** that reproduces the bug.
7
+ - [ ] Provide **screenshots** where appropriate
8
+ - [ ] What's the **version** of Python you're using?
9
+ - [ ] Are you using Mac, Linux or Windows?
.github/PULL_REQUEST_TEMPLATE.md ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ **IMPORTANT: Please do not create a Pull Request without creating an issue first.**
2
+
3
+ *Any change needs to be discussed before proceeding. Failure to do so may result in the rejection of the pull request.*
4
+
5
+ Please provide enough information so that others can review your pull request:
6
+
7
+ <!-- You can skip this if you're fixing a typo or adding an app to the Showcase. -->
8
+
9
+ Explain the **details** for making this change. What existing problem does the pull request solve?
10
+
11
+ <!-- Example: When "Adding a function to do X", explain why it is necessary to have a way to do X. -->
12
+
13
+ **Test plan (required)**
14
+
15
+ Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes UI.
16
+
17
+ <!-- Make sure tests pass on both Travis and Circle CI. -->
18
+
19
+ **Code formatting**
20
+
21
+ <!-- See the simple style guide. -->
22
+
23
+ **Closing issues**
24
+
25
+ Put `closes #XXXX` in your comment to auto-close the issue that your PR fixes (if such).
.gitignore ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ __pycache__/
2
+ env
Procfile ADDED
@@ -0,0 +1 @@
 
 
1
+ web: gunicorn app:app
README.md ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Flask_Basic
2
+ ![logo](https://github.com/prabhakarvenkat/Flask_Basic/blob/94bd3b3d6d8f4736188bff6dcead36b086ad8f5a/flask.png)
3
+
4
+ This repo has been updated to work with `Python v3.8` and up.
5
+
6
+ ## How To Run
7
+ 1. Install `virtualenv`:
8
+ ```
9
+ $ pip install virtualenv
10
+ ```
11
+
12
+ 2. Open a terminal in the project root directory and run:
13
+ ```
14
+ $ virtualenv env
15
+ ```
16
+
17
+ 3. Then run the command:
18
+ ```
19
+ $ .\env\Scripts\activate
20
+ ```
21
+
22
+ 4. Then install the dependencies:
23
+ ```
24
+ $ (env) pip install -r requirements.txt
25
+ ```
26
+
27
+ 5. Finally start the web server:
28
+ ```
29
+ $ (env) python app.py
30
+ ```
31
+
32
+ This server will start on port 5000 by default. You can change this in `app.py` by changing the following line to this:
33
+
34
+ ```python
35
+ if __name__ == "__main__":
36
+ app.run(debug=True, port=<desired port>)
37
+ ```
38
+
39
+ ## Contributing
40
+
41
+ Since this is a repository for an introduction, the code should remain the same as the code that was shown in the repository. Any pull requests that don't address security flaws or fixes for language updates will be automatically closed. Style changes, adding libraries, etc are not valid changes for submitting a pull request.
42
+ Thank you.
app.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, render_template, url_for, request, redirect
2
+ from flask_sqlalchemy import SQLAlchemy
3
+ from datetime import datetime
4
+
5
+ app = Flask(__name__)
6
+ app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///test.db'
7
+ db = SQLAlchemy(app)
8
+
9
+ class Todo(db.Model):
10
+ id = db.Column(db.Integer, primary_key=True)
11
+ content = db.Column(db.String(200), nullable=False)
12
+ date_created = db.Column(db.DateTime, default=datetime.utcnow)
13
+
14
+ def __repr__(self):
15
+ return '<Task %r>' % self.id
16
+
17
+
18
+ @app.route('/', methods=['POST', 'GET'])
19
+ def index():
20
+ if request.method == 'POST':
21
+ task_content = request.form['content']
22
+ new_task = Todo(content=task_content)
23
+
24
+ try:
25
+ db.session.add(new_task)
26
+ db.session.commit()
27
+ return redirect('/')
28
+ except:
29
+ return 'There was an issue adding your task'
30
+
31
+ else:
32
+ tasks = Todo.query.order_by(Todo.date_created).all()
33
+ return render_template('index.html', tasks=tasks)
34
+
35
+
36
+ @app.route('/delete/<int:id>')
37
+ def delete(id):
38
+ task_to_delete = Todo.query.get_or_404(id)
39
+
40
+ try:
41
+ db.session.delete(task_to_delete)
42
+ db.session.commit()
43
+ return redirect('/')
44
+ except:
45
+ return 'There was a problem deleting that task'
46
+
47
+ @app.route('/update/<int:id>', methods=['GET', 'POST'])
48
+ def update(id):
49
+ task = Todo.query.get_or_404(id)
50
+
51
+ if request.method == 'POST':
52
+ task.content = request.form['content']
53
+
54
+ try:
55
+ db.session.commit()
56
+ return redirect('/')
57
+ except:
58
+ return 'There was an issue updating your task'
59
+
60
+ else:
61
+ return render_template('update.html', task=task)
62
+
63
+
64
+ if __name__ == "__main__":
65
+ app.run(debug=True)
flask.png ADDED
gitattributes ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Unity ##
2
+
3
+ *.cs diff=csharp text
4
+ *.cginc text
5
+ *.shader text
6
+
7
+ *.mat merge=unityyamlmerge eol=lf
8
+ *.anim merge=unityyamlmerge eol=lf
9
+ *.unity merge=unityyamlmerge eol=lf
10
+ *.prefab merge=unityyamlmerge eol=lf
11
+ *.physicsMaterial2D merge=unityyamlmerge eol=lf
12
+ *.physicMaterial merge=unityyamlmerge eol=lf
13
+ *.asset merge=unityyamlmerge eol=lf
14
+ *.meta merge=unityyamlmerge eol=lf
15
+ *.controller merge=unityyamlmerge eol=lf
16
+
17
+
18
+ ## git-lfs ##
19
+
20
+ #Image
21
+ *.jpg filter=lfs diff=lfs merge=lfs -text
22
+ *.jpeg filter=lfs diff=lfs merge=lfs -text
23
+ *.png filter=lfs diff=lfs merge=lfs -text
24
+ *.gif filter=lfs diff=lfs merge=lfs -text
25
+ *.psd filter=lfs diff=lfs merge=lfs -text
26
+ *.ai filter=lfs diff=lfs merge=lfs -text
27
+ *.tif filter=lfs diff=lfs merge=lfs -text
28
+
29
+ #Audio
30
+ *.mp3 filter=lfs diff=lfs merge=lfs -text
31
+ *.wav filter=lfs diff=lfs merge=lfs -text
32
+ *.ogg filter=lfs diff=lfs merge=lfs -text
33
+
34
+ #Video
35
+ *.mp4 filter=lfs diff=lfs merge=lfs -text
36
+ *.mov filter=lfs diff=lfs merge=lfs -text
37
+
38
+ #3D Object
39
+ *.FBX filter=lfs diff=lfs merge=lfs -text
40
+ *.fbx filter=lfs diff=lfs merge=lfs -text
41
+ *.blend filter=lfs diff=lfs merge=lfs -text
42
+ *.obj filter=lfs diff=lfs merge=lfs -text
43
+
44
+ #ETC
45
+ *.a filter=lfs diff=lfs merge=lfs -text
46
+ *.exr filter=lfs diff=lfs merge=lfs -text
47
+ *.tga filter=lfs diff=lfs merge=lfs -text
48
+ *.pdf filter=lfs diff=lfs merge=lfs -text
49
+ *.zip filter=lfs diff=lfs merge=lfs -text
50
+ *.dll filter=lfs diff=lfs merge=lfs -text
51
+ *.unitypackage filter=lfs diff=lfs merge=lfs -text
52
+ *.aif filter=lfs diff=lfs merge=lfs -text
53
+ *.ttf filter=lfs diff=lfs merge=lfs -text
54
+ *.rns filter=lfs diff=lfs merge=lfs -text
55
+ *.reason filter=lfs diff=lfs merge=lfs -text
56
+ *.lxo filter=lfs diff=lfs merge=lfs -text
57
+ *.bc filter=lfs diff=lfs merge=lfs -text
requirements.txt ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ Click==7.0
2
+ Flask==1.1.2
3
+ Flask-SQLAlchemy==2.4.4
4
+ gunicorn==19.9.0
5
+ itsdangerous==1.1.0
6
+ Jinja2==2.11.3
7
+ MarkupSafe==1.1.1
8
+ SQLAlchemy==1.3.22
9
+ Werkzeug==1.0.1
static/css/main.css ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ body, html {
2
+ margin: 0;
3
+ font-family: sans-serif;
4
+ background-color: lightblue;
5
+ }
6
+
7
+ .content {
8
+ margin: 0 auto;
9
+ width: 400px;
10
+ }
11
+
12
+ table, td, th {
13
+ border: 1px solid #aaa;
14
+ }
15
+
16
+ table {
17
+ border-collapse: collapse;
18
+ width: 100%;
19
+ }
20
+
21
+ th {
22
+ height: 30px;
23
+ }
24
+
25
+ td {
26
+ text-align: center;
27
+ padding: 5px;
28
+ }
29
+
30
+ .form {
31
+ margin-top: 20px;
32
+ }
33
+
34
+ #content {
35
+ width: 70%;
36
+ }
templates/base.html ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <meta http-equiv="X-UA-Compatible" content="ie=edge">
7
+ <link rel="stylesheet" href="{{ url_for('static', filename='css/main.css') }}">
8
+ {% block head %}{% endblock %}
9
+ </head>
10
+ <body>
11
+ {% block body %}{% endblock %}
12
+ </body>
13
+ </html>
templates/index.html ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% extends 'base.html' %}
2
+
3
+ {% block head %}
4
+ <title>Task Master</title>
5
+ {% endblock %}
6
+
7
+ {% block body %}
8
+ <div class="content">
9
+ <h1 style="text-align: center">Task Master</h1>
10
+ {% if tasks|length < 1 %}
11
+ <h4 style="text-align: center">There are no tasks. Create one below!</h4>
12
+ {% else %}
13
+ <table>
14
+ <tr>
15
+ <th>Task</th>
16
+ <th>Added</th>
17
+ <th>Actions</th>
18
+ </tr>
19
+ {% for task in tasks %}
20
+ <tr>
21
+ <td>{{ task.content }}</td>
22
+ <td>{{ task.date_created.date() }}</td>
23
+ <td>
24
+ <a href="/delete/{{task.id}}">Delete</a>
25
+ <br>
26
+ <a href="/update/{{task.id}}">Update</a>
27
+ </td>
28
+ </tr>
29
+ {% endfor %}
30
+ </table>
31
+ {% endif %}
32
+
33
+ <div class="form">
34
+ <form action="/" method="POST">
35
+ <input type="text" name="content" id="content">
36
+ <input type="submit" value="Add Task">
37
+ </form>
38
+ </div>
39
+ </div>
40
+ {% endblock %}
templates/update.html ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% extends 'base.html' %}
2
+
3
+ {% block head %}
4
+ <title>Task Master</title>
5
+ {% endblock %}
6
+
7
+ {% block body %}
8
+ <div class="content">
9
+ <h1 style="text-align: center">Update Task</h1>
10
+
11
+ <div class="form">
12
+ <form action="/update/{{task.id}}" method="POST">
13
+ <input type="text" name="content" id="content" value="{{task.content}}">
14
+ <input type="submit" value="Update">
15
+ </form>
16
+ </div>
17
+ </div>
18
+ {% endblock %}
test.db ADDED
Binary file (8.19 kB). View file