Notes![what is notes.io? What is notes.io?](/theme/images/whatisnotesio.png)
![]() ![]() Notes - notes.io |
from sqlalchemy import Table, Column, Integer, String, MetaData, ForeignKey
from flask_sqlalchemy import SQLAlchemy
from flask.ext.restless import APIManager
#from flask_restless import APIManager
from flask import jsonify,request
from flask_marshmallow import Marshmallow
from flask_cors import CORS
from datetime import datetime
app = Flask(__name__)
cors = CORS(app, resources={r"/api/*": {"origins": "*"}})
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://root:root@localhost/MyBlog'
db = SQLAlchemy(app)
ma = Marshmallow(app)
class Katogoriler(db.Model):
__tablename__="katogoriler"
id = db.Column('id',db.Integer, primary_key = True)
katogori_ismi = db.Column("katogori_ismi",db.String(225))
yazilar=db.relationship('Yazilar', backref='kat')
class Kulanicilar(db.Model):
__tablename__="kulanicilar"
id=db.Column(db.Integer,primary_key=True)
kAdi=db.Column(db.String(225))
kSifre=db.Column(db.String(225))
kEposta=db.Column(db.String(225))
yazilar=db.relationship('Yazilar', backref='author')
class Yazilar(db.Model):
__tablename__="yazi_tablosu"
id=db.Column(db.Integer,primary_key=True)
yorumlar=db.relationship('Yorumlar', backref='yrum')
yazi_basligi=db.Column(db.String(225))
yazi_icerigi=db.Column(db.String)
yazi_yayin_tarihi=db.Column(db.Date, default=datetime.now())
katogori_id=db.Column(db.Integer, db.ForeignKey('katogoriler.id'))
yazar_id=db.Column(db.Integer, db.ForeignKey('kulanicilar.id'))
class Yorumlar(db.Model):
__tablename__="yorumlar"
id=db.Column(db.Integer,primary_key=True)
yazi_id=db.Column(db.Integer, db.ForeignKey('yazi_tablosu.id'))
yazar = db.Column(db.String(225))
yorum=db.Column(db.String)
isPublish=db.Column(db.Integer)
yTarihi=db.Column(db.Date, default=datetime.now())
manager=APIManager(app,flask_sqlalchemy_db=db)
#manager.create_api(Katogoriler)
#manager.create_api(Kulanicilar)
#manager.create_api(Yorumlar)
#manager.create_api(Yazilar)
class KatagoriSchema(ma.Schema):
class Meta:
# Fields to expose
fields = ('id', 'katogori_ismi')
katagori_schema = KatagoriSchema()
katagoriler_schema = KatagoriSchema(many=True)
class YazilarSchema(ma.Schema):
class Meta:
# Fields to expose
fields = ('id','yazi_basligi','yazi_icerigi','yazi_yayin_tarihi')
yazi_schema = YazilarSchema()
yazilar_schema = YazilarSchema(many=True)
class UserSchema(ma.Schema):
class Meta:
# Fields to expose
fields = ('id','kAdi','kEposta')
user_schema = UserSchema()
@app.after_request
def after_request(response):
response.headers.add('Access-Control-Allow-Origin', '*')
response.headers.add('Access-Control-Allow-Headers', 'Content-Type,Authorization')
response.headers.add('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE')
return response
@app.route("/katagoriler/")
def katagoriler():
katagoriler = Katogoriler.query.all()
result = katagoriler_schema.dump(katagoriler)
return jsonify(result.data)
@app.route("/yazilar/")
def yazilar():
yazilar = Yazilar.query.all()
result = yazilar_schema.dump(yazilar)
return jsonify(result.data)
@app.route("/login", methods=['GET', 'POST'])
def login():
content = request.json
print content
userr= Kulanicilar.query.filter_by(kEposta=content['email'],kSifre=content['password']).first()
r=user_schema.dump(userr).data
return jsonify(r)
@app.route("/newContent", methods=['POST'])
def insertContent():
content = request.json
print content
db.session.add(Yazilar(yazi_basligi=content['yazi_basligi'], yazi_icerigi=content['yazi_icerigi'], katogori_id=content['katogori_id'], yazar_id=content['yazar_id'] ))
db.session.commit()
return 'ok'
if __name__ == "__main__":
app.run(debug=True)
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team