Skip to content

Commit 9d605f3

Browse files
committed
Database Linking started
1 parent 03b08c2 commit 9d605f3

File tree

3 files changed

+10
-39
lines changed

3 files changed

+10
-39
lines changed

02.Flask/00.App.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ def hello():
1212

1313
@app.route("/page2")
1414
#/ ke baad url pe ye run hoga
15+
@app.route("/dusrapage")
16+
# can add multiple routes too
1517
def page2():
1618
return "you are in the second page"
1719

02.Flask/Bootstrap_Template.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
#Bootstrap Website se acha-acha templates download kar sakte hai for good frontend design
22

33
from flask import Flask, render_template
4+
from flask_sqlalchemy import SQLAlchemy
45

56
app = Flask(__name__)
7+
app.config["SQLALCHEMY_DATABASE_URI"] = "mysql+pymysql://sql12789398:tEkUSPU9G5@sql12.freesqldatabase.com/sql12789398"
8+
db = SQLAlchemy(app)
9+
10+
class User(db.Model):
11+
id: Mapped[int] = mapped_column(primary_key=True)
12+
username: Mapped[str] = mapped_column(unique=True)
13+
email: Mapped[str]
614

715
#Having same function to different routes
816
@app.route("/")

02.Flask/templates/index.html

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -32,45 +32,6 @@ <h3 class="post-subtitle">Problems look mighty small from 150 miles up</h3>
3232
</div>
3333
<!-- Divider-->
3434
<hr class="my-4" />
35-
<!-- Post preview-->
36-
<div class="post-preview">
37-
<a href="post.html"><h2 class="post-title">I believe every human has a finite number of heartbeats. I don't intend to waste any of mine.</h2></a>
38-
<p class="post-meta">
39-
Posted by
40-
<a href="#!">Start Bootstrap</a>
41-
on September 18, 2023
42-
</p>
43-
</div>
44-
<!-- Divider-->
45-
<hr class="my-4" />
46-
<!-- Post preview-->
47-
<div class="post-preview">
48-
<a href="post.html">
49-
<h2 class="post-title">Science has not yet mastered prophecy</h2>
50-
<h3 class="post-subtitle">We predict too much for the next year and yet far too little for the next ten.</h3>
51-
</a>
52-
<p class="post-meta">
53-
Posted by
54-
<a href="#!">Start Bootstrap</a>
55-
on August 24, 2023
56-
</p>
57-
</div>
58-
<!-- Divider-->
59-
<hr class="my-4" />
60-
<!-- Post preview-->
61-
<div class="post-preview">
62-
<a href="post.html">
63-
<h2 class="post-title">Failure is not an option</h2>
64-
<h3 class="post-subtitle">Many say exploration is part of our destiny, but it’s actually our duty to future generations.</h3>
65-
</a>
66-
<p class="post-meta">
67-
Posted by
68-
<a href="#!">Start Bootstrap</a>
69-
on July 8, 2023
70-
</p>
71-
</div>
72-
<!-- Divider-->
73-
<hr class="my-4" />
7435
<!-- Pager-->
7536
<div class="d-flex justify-content-end mb-4"><a class="btn btn-primary text-uppercase" href="#!">Older Posts →</a></div>
7637
</div>

0 commit comments

Comments
 (0)