mong , Flask

https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-mongodb-on-ubuntu-16-04?fbclid=IwAR0j2APdeVoL-8lQtql7o12_j3CR57d6nDEKVJMehWU9Zyrpg7n_aNQwdDI

mongo
show dbs
mongo -u nicole -p --authenticationDatabase admin

— Configuring
sudo systemctl restart mongod
sudo systemctl status mongod

— Testing the Remote Connection
mongo -u AdminSammy -p --authenticationDatabase admin --host IP_address_of_MongoHost

Start MongoDB
$ sudo service mongod start

Stop MongoDB.
$ sudo service mongod stop

Restart MongoDB.
$ sudo service mongod restart

================MongoDB Command ======================
use DATABASE_NAME
show dbs

insert many document
https://docs.mongodb.com/manual/tutorial/insert-documents/

youtube
https://www.youtube.com/watch?v=Phe9B2HRVmc

stackoverflow
https://stackoverflow.com/questions/11609647/import-more-than-1-json-file-using-mongoimport

github
https://gist.github.com/fabien0102/88dcaa184d801fd5e67a
ls -1 *.json | while read jsonfile; do mongoimport -d support -c logs -file $jsonfile --jsonArray -type json; done

--Import all files from a folder:

ls *.json | xargs -I filename
mongoimport -d targetDatabase -c targetCollection --file /home/myFiles/myJsonFile.json-u username -p password --authenticationDatabase admin

===================================
get web
wget URL (RAW DATA)
history | word
git clone
rm *.md

=======================================================================
AJAX:-> javascript 得到URL的 JSON content
var ourRequest = new XMLHttpRequest()
ourRequest.open('Get', 'https://learnwebcode.github.io/json-example/animals');
ourRequest.onload = function() {
var ourDate = JSON.parse(ourRequest.responseText);
console.log( ourData[0]);
}
ourRequest.send();
================================================

var pageCounter = 1;
var animalContainer = document.getElementById("animal-info");
AjAx: -> javascript 监听clicker
var btn = document.getElementById("btn");
btn.addEventListener("click" ,function(){
    var ourRequest = new XMLHttpRequest()
    ourRequest.open('Get', 'https://learnwebcode.github.io/json-example/animals-' + pageCounter + '.json');
    ourRequest.onload = function() {
      if(ourRequed=st.status >= 200 && ourRequest < 400) { // request 成功
        var ourDate =     JSON.parse(ourRequest.responseText);
        //console.log( ourData[0]);
        renderHTML( outData);
      }else {
          console.log("we connect to the server , but it returned an error");
      }
    
      }  // ourRequest.onload
    // handle the error request
    ourRequest.onerror = function(){
          console.log("connectin error ");
    }
    ourRequest.send();
    pangCounter ++; 
    if( pageCounter > 3) {
        btn.classList.add( "hide-me");
    }
} ); 

function renderHTML( data) {
var  htmlString = " ";   
for( i =0; i < data.length; i++) {
    htmlString +="

" + data[i].name + " is a "+ data[i].specise + "likes to eat " + ; for( ii=0; ii < data[i].foods.likes.length; ii ++){ htmlString += data[i].food.likes[ii]; } // for htmlString += '

'; } animalContainer.insertAdjacentHTML('beforeeend', htmlString); }

how do i find the JSON endpoint URLS ?
fill text JSON
ERROR handling for AJAX request ? -> RESTful

你可能感兴趣的:(mong , Flask)