-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3a92fa8
commit 301b54a
Showing
3 changed files
with
83 additions
and
16 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,36 @@ | ||
# fluthon | ||
|
||
A new Flutter project. | ||
|
||
## Getting Started | ||
|
||
This project is a starting point for a Flutter application. | ||
|
||
A few resources to get you started if this is your first Flutter project: | ||
|
||
- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) | ||
- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) | ||
|
||
For help getting started with Flutter, view our | ||
[online documentation](https://flutter.dev/docs), which offers tutorials, | ||
samples, guidance on mobile development, and a full API reference. | ||
# `Fluthon APP` | ||
|
||
A new Flutter project which is supported from a python script and lists quotes . | ||
|
||
|
||
## `Deployment` 📲 | ||
# | ||
```bash | ||
-> /Script - python main.py. | ||
|
||
``` | ||
``` | ||
-> Run main.dart in the flutter project. | ||
``` | ||
``` | ||
-> Fill in the data (Eg:- Motivation/Inspiration) in the provided space. | ||
``` | ||
|
||
## 🛠 `Libraries Used` | ||
# | ||
- Flask | ||
- request | ||
- jsonify | ||
- BeautifulSoup | ||
|
||
## 📱 `Demo ` | ||
# | ||
<h2 align= "left"><b>Quotes screen</b></h2> | ||
<p align="left"> | ||
|
||
<img width=40% src="Assets/i1.png">   | ||
|
||
## `LICENSE` | ||
# | ||
|
||
Licensed under the [MIT LICENSE](LICENSE). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
|
||
|
||
from flask import Flask , request , jsonify | ||
from bs4 import BeautifulSoup #used to pull out data from html , xml pages | ||
import requests | ||
|
||
app = Flask(__name__) | ||
|
||
|
||
@app.route('/api/v1/',methods=['GET']) | ||
def API(): | ||
if request.method == 'GET': | ||
uri = 'https://www.brainyquote.com' # source of data | ||
query = str(request.args['query']) | ||
print(query) | ||
if " " in query: | ||
query = str(query).replace(" ","+") | ||
else: | ||
pass | ||
|
||
search = '/search_results?q=' + query | ||
|
||
ready_uri = uri + search | ||
print(ready_uri) | ||
content = requests.get(ready_uri).content | ||
soup = BeautifulSoup(content, 'html.parser') | ||
quotes_links = soup.find_all('a', {'class': 'b-qt'}) | ||
l = [] #list | ||
for i in quotes_links: | ||
d = {} #dictionary | ||
quote_url = uri + i.get('href') | ||
quote_content = requests.get(quote_url).content | ||
quote_soup = BeautifulSoup(quote_content, 'html.parser') | ||
d['quote'] = quote_soup.find('p', {'class': 'b-qt'}).text #class | ||
d['author'] = quote_soup.find('p', {'class': 'bq_fq_a'}).text #class found using inspected elements | ||
l.append(d) | ||
|
||
|
||
return jsonify(l) #conversion to JSON format | ||
|
||
|
||
|
||
|
||
|
||
|
||
if __name__ == '__main__': | ||
app.run(port=5000) # any reference port is allowed |