Reputation: 444
I want to create a RESTful API using Python's PI web API. I tried to look for some help content but there is not much available. Anyone has any idea on how to begin implementing it. Please do not downvote my post. I do not have any other information to put with this post.
Upvotes: 0
Views: 75
Reputation: 155
you can look at flask as a good starting point. it's a python web server framework that should fill most of your needs. below is some sample code for a basic python flask app. The code is based off of this old project I worked on quite a while ago example.
you can probably find more example floating around that go into detail about flask. There are other libraries you can explore for database support and what not. you can mix and match and see what works.
__init__.py import os import sys import redis
from flask import Flask, render_template,redirect
from flask.ext.sqlalchemy import SQLAlchemy
from flask_kvsession import KVSessionExtension
from simplekv.memory.redisstore import RedisStore
from app.views.someModule import mod as someModule
app.register_blueprint(someModule)
someModule.py
from flask import Blueprint, request, render_template, flash, g, session, redirect, url_for, jsonify
from app import db
from app.model.problem import Problem
from app.model.solution import Solution
from app.model.account import Account
import string
import math
mod = Blueprint('problems', __name__, url_prefix='/problem')
@mod.route('/')
def problems():
return render_template("problems.html",
total = Problem.query.filter(Problem.userId != None).count())
@mod.route('/problem/<string:identifier>',methods=['POST'])
def problems(identifier):
''' do some logic with identifier '''
return jsonify(result = false)
Upvotes: 1