yusufgundogdu commited on
Commit
42dbe4b
·
verified ·
1 Parent(s): ee6afd3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -15
app.py CHANGED
@@ -5,26 +5,19 @@ from database import init_db, close_db
5
 
6
  app = Flask(__name__)
7
 
8
- # Veritabanı başlatma
9
- with app.app_context():
10
- init_db()
11
 
12
- # Ana sayfa
13
- @app.route('/')
14
- def home():
15
- return "StableDiffusionAPI Türkçe"
16
 
17
- # GET Endpoint'leri
18
- app.route('/users', methods=['GET'])(get_users)
19
- app.route('/user/<int:user_id>', methods=['GET'])(get_user)
20
-
21
- # POST Endpoint'leri
22
- app.route('/add-user', methods=['POST'])(add_user)
23
-
24
- # Veritabanı bağlantısını kapat
25
  @app.teardown_appcontext
26
  def shutdown_session(exception=None):
27
  close_db()
28
 
29
  if __name__ == '__main__':
 
 
 
 
 
30
  app.run(host='0.0.0.0', port=7860)
 
5
 
6
  app = Flask(__name__)
7
 
8
+ # Veritabanını başlat (app context'i ile)
9
+ init_db(app)
 
10
 
11
+ # ... (diğer route tanımlamaları aynı)
 
 
 
12
 
 
 
 
 
 
 
 
 
13
  @app.teardown_appcontext
14
  def shutdown_session(exception=None):
15
  close_db()
16
 
17
  if __name__ == '__main__':
18
+ # Veritabanı dizinini kontrol et
19
+ from database import get_db_path
20
+ db_path = get_db_path()
21
+ os.makedirs(os.path.dirname(db_path), exist_ok=True)
22
+
23
  app.run(host='0.0.0.0', port=7860)