Python

August 3rd, 2024suno

Lyrics

from flask import Flask, request, jsonify from flask_sqlalchemy import SQLAlchemy from flask_cors import CORS app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///functions.db' db = SQLAlchemy(app) CORS(app) class Function(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(100), nullable=False) description = db.Column(db.String(200), nullable=False) language = db.Column(db.String(100), nullable=False) with app.app_context(): db.create_all() @app.route('/api/functions', methods=['GET']) def get_functions(): functions = Function.query.all() results = [ { 'id': func.id, 'name': func.name, 'description': func.description, 'language': func.language } for func in functions ] return jsonify(results) @app.route('/api/functions/search', methods=['GET']) def search_functions(): query = request.args.get('query', '') language = request.args.get('language', '') functions = Function.query.filter( Function.description.ilike(f'%{query}%'), Function.language.ilike(f'%{language}%') ).all() results = [ { 'id': func.id, 'name': func.name, 'description': func.description, 'language': func.language } for func in functions ] return jsonify(results) @app.route('/api/functions', methods=['POST']) def add_function(): data = request.get_json() if 'name' not in data or 'description' not in data or 'language' not in data: return jsonify({'error': 'Bad Request', 'message': 'Missing name or description or language'}), 400 new_function = Function(name=data['name'], description=data['description'], language=data['language']) db.session.add(new_function) db.session.commit() return jsonify({'message': 'Function added'}), 201 @app.route('/api/functions/<int:id>', methods=['DELETE']) def delete_function(id): function = Function.query.get_or_404(id) db.session.delete(function) db.session.commit() return jsonify({'message': 'Function deleted'}) if __name__ == '__main__': app.run(debug=True)

Recommended

Symphony of Grace
Symphony of Grace

instrumental classical piano style of Beethoven light elegant entertainment

Lost in Aisle Five
Lost in Aisle Five

mellow smooth lounge

ethnic girl
ethnic girl

bossa nova, danceable rhythm, repetitive bassline, tropical beach, electric guitar and base, piano, maracas

Train
Train

fun, children, pop indie

Nakuja
Nakuja

male voice, groovy bass, tanzanian accent, upbeat R&B Bongo flava

Neon Dreamscape
Neon Dreamscape

Melodic,synth and techno pop,atmospheric,

Pit Stop
Pit Stop

Alternative rock emotional piano melodic male

Labyrinth of Compliance
Labyrinth of Compliance

female vocalist,rock,dark,atmospheric,sombre,melancholic,lonely,poetic,singer-songwriter

Таїті v2
Таїті v2

piano klezmer

Tercios de Flandes
Tercios de Flandes

male voice, us power metal, clear voice, epic metal, awesome riffs

uwu who are u
uwu who are u

gentle female vocals, soft melody, abrupt industrial witch

Dazzling Slash
Dazzling Slash

industrial metal, 90s electronic, epic

Lofi piano music
Lofi piano music

lo fi piano music

Shadows of the Street
Shadows of the Street

Dark, slow, Serious, Thriller, Whispers, electric guitar, drums, rap, spy

Imagine The Light
Imagine The Light

gospel piano-driven uplifting

Believing in the Dream
Believing in the Dream

Alternative Rock Progressive Rock

Ya Rasulullah Cinta Kami
Ya Rasulullah Cinta Kami

electropop, pop, synth, melancholic

Bossfight
Bossfight

electronic 16-bit, dubstep