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)

Empfohlen

Lidový hardbass
Lidový hardbass

hardcore hardbass, european, fast-paced, male singer

Scat that Chat
Scat that Chat

VOCALOID electronica, house

Flying High II
Flying High II

house, techno, Atmospheric minimal, deep, electronic, bass, drum, guitar, violin, electro, dramatic, alternative rock,

The man Called Lennarth (The tragic tale of Lennarth Bladh)
The man Called Lennarth (The tragic tale of Lennarth Bladh)

Introspective rap vibes: haunting melodies, resilience amidst chaos, redemption and authenticity. Dive into the journey

Moonlit Farewell
Moonlit Farewell

pop,electronic,j-pop,synth-pop,anime

Crimson Cascade
Crimson Cascade

anthemic, dark surf, garage screamo, bouncy, choppy riffs, stomp, tribal, chanting, ominous, NYC punk

The Bear Family
The Bear Family

Upbeat folk-pop song

Rise Up and Shine
Rise Up and Shine

Soulful gospel choir, powerful lead vocals, uplifting messages, organ accompaniment, and handclaps

Analiki z Pracy Wylatuje
Analiki z Pracy Wylatuje

pop acoustic ballad

Pressure
Pressure

Fire, Miku voice, Vocaloid, math rock, j-pop, mutation funk, bounce drop, hyperspeed dubstep

Midnight Sun
Midnight Sun

funny hip hop fast rap with a remembering melodie

Хокку
Хокку

cloud dream heartfelt french reggaeton

Stationnetje Ritme
Stationnetje Ritme

hip hop,rap,english,hiphop/rap/r&b,dutch

nope, never
nope, never

Neo melodic trap, numb sound-cloud sad boi rap

Cozy Nights
Cozy Nights

acoustic lo-fi romantic

Mis siete deseos para ti
Mis siete deseos para ti

pop, techno, space techno, space pop, space opera, female singer, pop singer, fast tempo, jolly