I'm going to create a large scale web application using Django.
It has 2 main parts website and API. also in API I have different modules(controller) like user, event and some other layers things like security, utility ...
I'm looking for an enterprise architecture.
Use django to create a website and then expose whatever you want with django-tastypie as an API: https://github.com/toastdriven/django-tastypie
Related
I have backend of web app by django, include registrations/user profile,
the ability to add photo(video) file and view them, and list of places with the ability to book them.
Now I need to add the ability to work with a mobile application written in ReactJS.
The problem is that before that I did not work with mobile applications and I do not know what strategy to choose, but the frontend developer did not work with the backend. Can I pass django variables directly to the ReactJS code? Do I need additional technologies or frameworks? I would be grateful if someone shared their experience and described how to do it (preferably the least simple way)
You have to build a REST API. In your case, the best solution would be creating the API with Django REST Framework.
It is a very powerful framework for building APIs. They provide some nice tutorials to get started with it.
After that, you can create the frontend app with React by using API calls.
Let us assume that, I have a Machine Learning model which uses the Tensorflow library and performs a function.
And of course, the function requires input and provides some output. Which can be easily done on my terminal.
Here comes the area where I need help, IO in the terminal is not what I wanted, I want to create a web application that has multiple functionalities. Let us only consider the area where my ML model has to work, say when I click a button after entering the inputs it runs the ML model back and provides me an output which I could display it on my web application.
I can develop websites with NodeJs. Is there any possibility of integrating the ML model with my web application made of NodeJs?
I tried running on some packages like child-process,python-shell nothing works, it gives me an error when it comes to the place of importing packages.
Please give me suggestions on the Integration of the ML model with a NodeJS web application using MongoDB as a database. All I wanted is that my web application runs my ML model wherever necessary to obtain the results which I can display through my web applications.
Also, provide information about technologies that can be easily integrated with the Machine learning model.
I'm also encountering similar problems.
Further to the previous reply, I would go for the micro services architecture design.
E.g. Use a node.js app to serve the front-end request, and the Python server only to serve the machine learning tasks.
You need to build a python web application around your model to serve responses (your model’s output) to the client (the webpage your nodejs app is serving).
Flask and Django are the major players there. REST is the most popular meta-framework.
Once you’ve built a REST API around your model, you just query it like any resource via HTTP/xmlhttprequest in JavaScript from your web page.
Or you can try to pickle your model and load into into JavaScript to query from your nodejs app.
Easier than either of those would be to use IBM Cloud Functions or AWS Lambda to expose your script/model. Very easy and cost effective.
I have previous experience with a moderately complex Flask + AngularJS application. But now I'm starting on a new more complex app and need help in how I need to setup both the Python and AngularJS application. Here are some info about the app.
The back-end is Python (Flask) app using Pandas to manipulate data
The Python will have an api for the front-end and also a public api
The front-end will be AngularJS SPA with mostly Google Charts
The app will have a both a free and paid version
The paid version will show more charts than the free version
There will also be some static pages for info, pricing, signup, login
Prefer to use a single Postgres DB for both free and paid
My thoughts are to divide each of the backend and front-end into separate modules. I was looking into using Blueprint in Flask to separate the free and paid apps. On the front-end I would prefer to have charts as modular directives that can be copied from free to paid or vice versa.
I'm not clear on how best to setup the folder structure of the Python app and the where the AngularJS files will reside. I also would prefer the free and paid app to be modular so that developers can work on each separately without effecting the other.
Questions:
Is a Microservice Architecture a better approach?
Should the free and paid app be one code base or completely separate
Is Blueprint the best approach with Flask or should the Python apps be completely separate?
What is a good domain strategy to use for free/paid? (e.g. should paid be a subdomain like admin.example.com and free example.com/dashboard or similar)
I'd start by doing something like this:
Create a Github repo named mysite-www. This repo will hold your HTMl / CSS / Angular code only and be deloyed as a static site to something like Amazon S3 / Cloudfront. This means your front-end will be very fast and not dependent on any backend code.
Create a Github repo named mysite-api. This repo will hold your Flask code and be deployed to a dynamic server infrastructure like Heroku / EC2 / Elastic Beanstalk.
Now you have that stuff setup, let's talk about your Flask API project.
You should have one codebase for both the free and paid version of your product. It doesn't make sense to separate these into separate projects as you'll be using 99% of the same code.
You should have some flags set on your user account, which tells you (and subsequently, your Angular front-end), if the user is a paid or free user, and then limits functionality based on those user settings.
You should always use blueprints with Flask if you have any moderately complex API. Blueprints let you have nice nested folders of Python code, that all control separate parts of your API / website.
Now, in general:
Have a single domain for your free / paid product. When a user signs up, let them choose a plan.
Don't change product URLs based on if the user is free or paid, both users should be directed to www.mywebsite.com/dashboard when logged in.
Depending on how you want to authenticate your users between your front-end and API, you likely want to use the OAuth2 protocol. I work for a company that makes this sorta thing easy, re: http://flask-stormpath.rtfd.org/, but there are lots of other great options too: Flask-Security, Flask-Login, etc.
Good luck!
I am looking for a 'sanity check' before I start working on this, as I'm new to writing server-side code. I want to stick to Python if possible, since that's what I'm used to!
I have written a desktop app (wxPython) that allows offsite employees to record their working times, the results of which they currently email to the company. I want to be able to have them save data directly to an 'online' location, from which the company can get summary data.
From what I have read (mostly here on StackOverflow) leads me to think I should do the following:
Run a database on the server with local access only (I'm favouring RethinkDB...)
Write a Python server app that can access the database but only exposes the functionality needed per user. Probably with different ports for users, payroll, and admin (me). Secure the sockets with TLS.
Add code to the desktop app to access the server.
Is this a good approach, or am I reinventing wheels and should learn to use Django or some other web framework?
As Paulo Almeida suggested in the comments making a REST application you interface with your wxPython application is probably the way to go. For this django may be a solution but it is probably an overkill microframework such as web.py, flask or bottle is enough and more easier to grasp
I need to create web application, which can be reached by user as regular web site and as XML-RPC web service. Also web site should have mobile version. I'm planning to use next technologies:
Django (for web frontends (regular and mobile)).
Pyramid (for web service).
SQLAlchemy, Memcached (for persistence level)
Later other projects can reach this data and providing logic, so I think it is better to make two tiers. I see it in next way:
Tier 1. Main logic service level. This level will provide API for frontend applications (Django powered web site, for example).
Tier 2. Different mostly end client applications (web site, API for remote client devices).
For communication between this tiers I'm planning to use XML-RPC protocol.
In this case it will be easy to scale it and add new front end application or connect another projects to this (I believe it).
I have main question, -- what can I use to make it easy build first tier? Maybe there is some framework good for that?
And what do you think about this whole architecture. Because I'm filling that I'm thinking in Java terms developing in Python. Maybe there is some another idioms in Python world for such situations.
Thanks for you time and help.
P. S.
Some links for reading are welcome.
This architecture really makes no sense. You're using Django, a full-stack web framework, for the front end, but not using it for the database. And you're using Pyramid, another full-stack web framework, for the web service side, thus ensuring that you duplicate all the business logic.
Much as I am an advocate of Django, I would say it has no place in your architecture. It looks like the only thing you're really using it for is URL routing and templates, both of which Pyramid does itself fine - you can even use Jinja2, which is based on Django's template language, as the template language in Pyramid if you like.
Doing it this way means that you can share the business logic between the front-end and web service code, since you'll almost certainly find that a lot of it will be the same.
I must say also that I don't understand the division into tiers, which you have described as separate from the front-end/web service division. To me, the web service is the second tier. It makes no sense to have a further division.
You should checkout the Turbogears framework as it is composed of several popular components: ORM with sqlalchemy, pylons for logic and support for WSGI, permits support for several templating engines for the frontend... endless.
I use it for several web-services behind AJAX-enabled front-ends (like Flex-based apps, among others). You can front end the TG2-based webapp with apache or your favorite WSGI-enabled web server too.
Checkout their website since they have a tutorial to setup a wiki in 20 minutes.
Cheers!