How to run django app in allen NLP environment? - django

I have created an API in Django. It is supposed to take a request and pass the argument to allenNLP files to gather a computed response. I want to know how to run my django app in allenNLP environment and I want all the source code of allenNLP to be in a folder in my django project. Is it possible and how can I do it?

What you're looking for is running AllenNLP inside django.
You can add AllenNLP libraries in your requirements.py. Next, the .py file can be stored in any of your source code hierarchy.
In your views.py, where you are getting request and extracting parameters, you can call the .py file which contains allennlp source code.
Not sure about what AllenNLP files you're talking about, if it's code files, they can go in your regular source code folder, if it's a static files, like Image, CSV etc, they need to go in static folder.
Please clar my understanding of your requirement if the answer doesn't address your question.

Related

Django file explorer

I need to create a Django file explorer. It needs to perform a similar function to the Simplehttpserver that comes with python. The main purpose is rendering static HTML files and making certain directories available for TEST users or ITOPS users etc. Need some advice on how to do this.

Django save large files

I'm creating a website where the user is able to upload large files. Around 100-300Mb. I'm using django but I want to know what is the best option to save the files. Should I just add them to my user database? Or should I create a media folder and save the files there. If so then this would mean that I have to save the name of the file in my user database?
Please let me know how you would tackle this issue.
django does not store files in the database, but in media folder. The FileField contains the path to the file(in the media folder). You can change that behavior but it is not recommended(as general practice). What you should consider however is that files of that size will require some more work both in django and the front-end since the upload process will freeze the server. A potential solution to the problem is this: https://pypi.org/project/django-chunked-upload/

Templates Folder in Magnolia CMS 5

I am setting up a Magnolia-based website and trying to place a template script into the templates folder in the webapp. However, I cannot find that folder anywhere. All tutorials say that, if I go to this directory magnolia-5.0/apache-tomcat-7.0.40/webapps/magnoliaAuthor in my enviroment, I can get it, but I haven't managed it.
I attach an screenshot of my magnoliaAuthor folder in which every folder that is supposed to be there actually is, except for the only one that I need (templates).
Hope you can help me with this. Thanks!
What kind of template?
If it is jsp, you can just place it anywhere you want in that folder and reference it from the template definition.
If it is freemarker template, those are by default served from either the classpath or from repository, so for testing you can just upload it to the repo via templates app http://yourtomcat:port/magnoliaAuthor/.magnolia/admincentral#app:templatesApp:;
BTW if you install samples module (add magnolia-templating-samples.jar in your WEB-INF folder), it will create folder "templates" in your webapp and extract sample jsp templates in that folder.
HTH,
Jan

where is the Yuidoc data.json address for ember?

I want to merge the ember.js documentation into my local yuidoc documentation for my project since many of my objects extend Ember Objects.
The Yuidoc Documentation says I can put a property "external.data" in my yuidoc.json file with the address to an external data.json file. Is this file available? If not, can it be made available so those of us documenting our ember projects can auto-sync to ember's documentation?
I believe the file is generated when you run 'yuidoc .' and it is located in the same dir as the index.html file that is built for API documentation (the root of the api docs). There is a file in the git repo here that looks like it might've been generated by this data.json file but it obviously does not contain json format. It would be nice if this data.json file were made available at the root of the published api docs on the ember website
We don't currently commit this file. Can you open an issue on https://github.com/emberjs/website so we can address this?

Django: How to use static files (simple case, jquery)

I am trying to use jQuery on a Django site. I need to include the jQuery.js library. I have read a lot about Django static files, but I don't think anyone has asked this particular question. I have only three static files to serve: jquery.js, anothersmallfile.js, and styles.css. The Django docs on static file serving say:
"For small projects, this isn’t a big deal, because you can just keep the static files somewhere your web server can find it. link
I would like to "just keep them somewhere my webserver can find them" because elsewhere the Django docs clearly state (warn) that their static-files serving method is only for a development environment. I only have a few static files and I just want the simplest secure solution.
Unfortunately I can't get it working. No matter where I put the files, Django can't find them. Debugging through Chrome web developer console I see I'm getting a 404 error:
GET http://127.0.0.1:8000/templates/polls/jquery.js 404 (NOT FOUND)
I am new to running a server. Do I A.) need to tell my urls.py file where to find static files? or perhaps the problem is B.) that I have misunderstood this issue - Django is my webserver (for production) so right now I must use the Django static files solution?
Doesn't seem like it ought to be very difficult to get my templates to simply recognize a .js file that's in the same directory as they are. Am I missing something?
Edit, before I get more downvotes: I am talking about this passage from the page linked above:
///////////////////////
Django developers mostly concern themselves with the dynamic parts of web applications – the views and templates that render anew for each request. But web applications have other parts: the static files (images, CSS, Javascript, etc.) that are needed to render a complete web page.
For small projects, this isn’t a big deal, because you can just keep the static files somewhere your web server can find it. However, in bigger projects – especially those comprised of multiple apps – dealing with the multiple sets of static files provided by each application starts to get tricky.
That’s what django.contrib.staticfiles is for: it collects static files from each of your applications (and any other places you specify) into a single location that can easily be served in production.
///////////////////
Emphasis added
So if that's what django.contrib.staticfiles is for, what's the simpler solution? I dispute that this is a repeat of prior questions.
You need to read that documentation more closely. That warning is for production. In development, you do use that static-serving method, ie putting it in your urls.py. And, that documentation will also show that the templates directory is not the right place to put them: a separate static or media directory is.
Edit after comment I really don't understand your comment. Either you do it in development via the static serving view, or you use your production server. But you say you don't have a production server. When you get one, whether it's Apache or Nginx or whatever, you put your static files in a directory and tell that server to serve files from there. That is the simple solution. The staticfiles app, exactly as in the docs you quoted, are for when you've got lots of files in different apps (and it simplifies the move from development to production, not complicates it as you seem to think).
Suppose your app is www.
setting.py -> STATIC_ROOT = 'static/'
make dir www/static
make file www/static/some.html
in browser localhost:8000/static/some.html
That's all.