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

Daydream Landscapes
Daydream Landscapes

electronic dreamy indie pop

Golden Clockwork Whispers
Golden Clockwork Whispers

Neo-Victorian Symphonic Steampunk with Industrial Influences, Atmospheric Clock Noises

Song for you
Song for you

pop punk, heavy bass male vocal, progressive rock

Awesome Chiptune A Finito
Awesome Chiptune A Finito

Progressive Melodic Chiptune, Wide Stereo

Abundance Flows to Me
Abundance Flows to Me

Uplifting, serene Caribbean music. energic Joyful upbeat energy fun happy dance

Taco Bell Fury
Taco Bell Fury

male vocalist,nu metal,metal,alternative metal,rock,dark,heavy,rhythmic,angry,aggressive,hateful,dense

Broken Promises
Broken Promises

Emo Punk, heavy rock, punk, duet

Du e^ no
Du e^ no

techno, modern trap, ambient

Flames of Destiny
Flames of Destiny

electronic,electronic dance music,melodic,energetic,uplifting,party,warm,progressive house,electro house,repetitive,trance,progressive trance

Pain
Pain

melancholic grunge

Warrior's Anthem
Warrior's Anthem

epic instrumental tavern music celtic

Dream Big greg2
Dream Big greg2

Hard Rock, metal

Flip-Flop Disco
Flip-Flop Disco

electronic club mix deep bass

City Streets
City Streets

electric blues dark fuzz heavy bass guitar riff blues solo high emotion

Warriors of the Cubicle
Warriors of the Cubicle

rock metal growl gritty

Suwe Ora Jamu - nu metal
Suwe Ora Jamu - nu metal

nu metal with little female vocal

Is There Anybody Out There
Is There Anybody Out There

atmospheric indie-pop dreamy, male vocals

ABC Anarchy
ABC Anarchy

1980s hardcore punk, male vocalist, fast-tempo, edgy

Fashionable Melodies
Fashionable Melodies

sophisticated jazzy smooth