-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapptest.py
More file actions
31 lines (21 loc) · 748 Bytes
/
Copy pathapptest.py
File metadata and controls
31 lines (21 loc) · 748 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# apptest.py
from flask import Flask, request, render_template
import sqlite3
app = Flask(__name__)
# Database initialization
conn = sqlite3.connect('comments.db')
c = conn.cursor()
c.execute('''CREATE TABLE IF NOT EXISTS comments (id INTEGER PRIMARY KEY AUTOINCREMENT, comment TEXT)''')
conn.commit()
@app.route('/')
def index():
return render_template('index.html')
@app.route('/submit', methods=['POST'])
def submit_comment():
comment = request.form['comment']
# Vulnerability: SQL Injection
c.execute("INSERT INTO comments (comment) VALUES ('%s')" % comment)
conn.commit()
return "Comment submitted successfully!"
if __name__ == '__main__':
app.run(debug=True)